1
我先使用EF代码,并在我的迁移文件中包含以下内容。EF - 未设置列默认值
public override void Up()
{
AddColumn("dbo.ConsumerFee", "VATCodeId", c => c.Int(nullable: false, defaultValue: 1));
}
然而,当列被添加到它被赋予的默认值为0表中未1.当我运行迁移手动我可以看到,它产生此SQL:
alter table `ConsumerFee` add column `VATCodeId` int not null
不限想法可能与此有关吗?
不适用于EF6。见[这里](http://stackoverflow.com/questions/20136504/how-can-set-a-default-value-constraint-with-entity-framework-6-code-first) –