My EF5 model
public Layout()
{
public int Id {get;set}
public BindingList<Column> Columns {get;set}
}
public Column()
{
public int Id {get;set}
public string Name {get;set}
[Required]
[ForeignKey("LayoutId")
public virtual Layout Layout {get;set}
public int LayoutId {get;set}
}
In my context I only need to specify
DBSet<Layout> Layouts {get;set}
I dont need to specify DBSet Columns for the database to create the way I want it with both tables.
Also I am happy in my code to only ever access columns via the layout object However i cant figure out how to persist the layout object with its columns correctly.
This question here describes how to save parent objects with children, but it would require me to create a DBSet Columns property in my context. Do I really have to do that?