【发布时间】:2012-07-17 18:41:52
【问题描述】:
我有一个如下所示的课程:
[Table("Subscribers", Schema = "gligoran")]
public class Subscriber
{
[Key]
public string Email { get; set; }
[Required]
[DefaultValue(true)]
public bool Enabled { get; set; }
}
在创建包含此类的迁移时,我得到:
public partial class AddSubscriberClass : DbMigration
{
public override void Up()
{
CreateTable(
"gligoran.Subscribers",
c => new
{
Email = c.String(nullable: false, maxLength: 128),
Enabled = c.Boolean(nullable: false),
})
.PrimaryKey(t => t.Email);
}
public override void Down()
{
DropTable("gligoran.Subscribers");
}
}
我希望Enabled 行看起来像这样:
Enabled = c.Boolean(nullable: false, defaultValue: true),
我当然可以自己做,但我只是想问问有没有办法让 Entity Framework 自动做。
我正在使用最新的 Entity Framework 5 RC (5.0.0-rc.net40)。
【问题讨论】:
标签: c# entity-framework-migrations entity-framework-5