Initialize a property in Entity Framework that already has a constructor
Is there ANY way to initialize a property in an Entity Framework entity
that has a collection?
This is the generated code for an Entity that has a collection:
public partial class MyEntity
{
public MyEntity()
{
this.MySubEntities = new HashSet<MySubEntity>();
}
public bool IsActive {get; set;}
public virtual ICollection<MySubEntity> MySubEntities {get; set;}
}
If I need to make a new MyEntity that I want to default to IsActive =
true, it cannot be done! (Unless I edit the T4 template.)
Please tell me there is a way to default IsActive = True without editing
the generated file (or the T4).
No comments:
Post a Comment