Document、、、の3つのモデルがSectionありParagraphます。それぞれがこのように見えます。
// Document
public class Document
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Section> Sections { get; set; }
}
// Section
public class Section
{
public int Id { get; set; }
public int DocumentId { get; set; }
public virtual Document Document { get; set; }
public virtual ICollection<Paragraph> Paragraphs { get; set; }
}
// Paragraph
public class Paragraph
{
public int Id { get; set; }
public int SectionId { get; set; }
public virtual Section Section { get; set; }
}
Section.Paragraphsエンティティは、。のすべての段落を自動的に入力しSectionId == Idます。ただし、これは発生していませんDocument.Sections。、がnullDocument.Sectionsであるすべてのセクションが入力される代わりに、ああ!DocumentId == idDocument.Sections