MVC3 and EF5: Including Child and GrandChild entities in the View <p>To make things simple, I have 3 entities (one to many, left to right):</p> <p>COURSE -> MODULE -> CHAPTER</p> <p>A course can have multiple modules and a module can have multiple chapters.</p> <p>All I have in the controller is this:</p> <pre><code>Course course = db.Courses.Find(id); return View(course); </code></pre> <p>I was trying to use an include but it doesn't seem to evaluate (this doesn't seem to work: <code>Course course = db.Courses.Include("Modules").Find(id);</code>)</p> <p>So I let it be. In my view, I have this nested List:</p> <pre><code>&lt;ul&gt; @foreach (var item in Model.Modules) { &lt;li&gt;@module.Title &lt;ul&gt; @foreach (var item in module.Chapters) { &lt;li&gt;@chapter.Title&lt;/li&gt; } &lt;/ul&gt; &lt;/li&gt; } &lt;/ul&gt; </code></pre> <p>Will this work automatically?</p> <p>Lastly, I applied a SortOrder column so I could arrange the child entities. I know that this should be done in the query, but how can I do this?</p> <p>Thanks! Any piece of information or advise would be highly appreciated.</p> <p><strong>UPDATE</strong></p> <p><strong>Course Class</strong></p> <pre><code>public partial class Course { public Course() { this.Modules = new HashSet&lt;Module&gt;(); this.Assets = new HashSet&lt;Asset&gt;(); } public int Id { get; set; } public string Name { get; set; } public string Description { get; set; } public string Author { get; set; } public System.DateTime CreateDate { get; set; } public bool IsDeleted { get; set; } public int IndustryId { get; set; } public virtual ICollection&lt;Module&gt; Modules { get; set; } public virtual ICollection&lt;Asset&gt; Assets { get; set; } public virtual Industry Industry { get; set; } } </code></pre> <p><strong>Module Class</strong></p> <pre><code>namespace RocketLabs.Models { using System; using System.Collections.Generic; public partial class Module { public Module() { this.Chapters = new HashSet&lt;Chapter&gt;(); this.Assets = new HashSet&lt;Asset&gt;(); } public int Id { get; set; } public string Title { get; set; } public System.DateTime CreateDate { get; set; } public int CourseId { get; set; } public bool IsDeleted { get; set; } public short SortOrder { get; set; } public virtual Course Course { get; set; } public virtual ICollection&lt;Chapter&gt; Chapters { get; set; } public virtual ICollection&lt;Asset&gt; Assets { get; set; } public virtual Exam Exam { get; set; } } } </code></pre> <p><strong>Chapter Class</strong></p> <pre><code>namespace RocketLabs.Models { using System; using System.Collections.Generic; public partial class Chapter { public Chapter() { this.Assets = new HashSet&lt;Asset&gt;(); } public int Id { get; set; } public string Title { get; set; } public int ModuleId { get; set; } public string Notes { get; set; } public short SortOrder { get; set; } public System.DateTime CreateDate { get; set; } public bool IsDeleted { get; set; } public virtual Module Module { get; set; } public virtual ICollection&lt;Asset&gt; Assets { get; set; } } } </code></pre>