次のようなクラスがあります。
[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) を使用しています。