I am using Entity Framework 5 Code First and I have the following model:
class Document
{
public int Id {get;set;}
public String Name {get;set;}
public IList<Page> Pages {get;set;}
}
class DocumentTemplate
{
public int Id {get;set;}
public String Description {get;set;}
public String Name {get;set;}
public IList<Page> Pages {get;set;}
}
class Page
{
public int Id {get;set;}
public string Text {get;set;}
}
I know how to match an identifying relationship in which a child has 1 parent. But I would like to map the Page object so that it has an identifying relationship for each parent.
In addition, parental relationships are mutually exclusive. A separate page will either belong to a DocumentTemplate, or to a document, and not both.
Is such a mapping possible in Entity Framework 5?
I do not want to create separate objects for the page, because they will be essentially the same, except for the parent relationship.
TIA.