Entity Framework 6 Code first Default value
问题 is there \"elegant\" way to give specific property a default value ? Maybe by DataAnnotations, something like : [DefaultValue(\"true\")] public bool Active { get; set; } Thank you. 回答1: You can do it by manually edit code first migration: public override void Up() { AddColumn("dbo.Events", "Active", c => c.Boolean(nullable: false, defaultValue: true)); } 回答2: It's been a while, but leaving a note for others. I achieved what is needed with an attribute and I decorated my model class fields