title: ASP.NET:The ObjectContext instance has been disposed
body: <p>I am new in entity framework and ASP.NET. i am trying to access attributes of navigation properties. but i am facing the "The ObjectContext instance has been disposed" error. than i have do some google and found that it can be fixed by the <code>data = db.tblCourses.Include(c =&gt; c.tblSection).ToList();</code> but i am still facing the problem. 
  Model: </p>
  
  <pre><code>using System.Data.Entity;
  public List&lt;tblCourse&gt; editedCoursesView()
  {
      List&lt;tblCourse&gt; data;
      using (enrolmentsystemEntities db = new enrolmentsystemEntities())
      {
          data = db.tblCourses.ToList();
          data = db.tblCourses.Include(c =&gt; c.tblSection).ToList();
          return data;
      }
  }
  </code></pre>
  
  <p>tblCourse: </p>
  
  <pre><code>namespace enrolmentSystem.Models
  {
      using System;
      using System.Collections.Generic;
  
      public partial class tblCourse
      {
          public tblCourse()
          {
              this.tblenrolments = new HashSet&lt;tblenrolment&gt;();
          }
  
          public int CourseId { get; set; }
          public string CourseName { get; set; }
          public int departmentID { get; set; }
          public int TeacherId { get; set; }
          public int CreditHours { get; set; }
          public int SectionId { get; set; }
  
          public virtual tbldepartment tbldepartment { get; set; }
          public virtual tblteacher tblteacher { get; set; }
          public virtual ICollection&lt;tblenrolment&gt; tblenrolments { get; set; }
          public virtual tblSection tblSection { get; set; }
      }
  }
  </code></pre>
  
  <p>tblRoom :</p>
  
  <pre><code>    namespace enrolmentSystem.Models
  {
      using System;
      using System.Collections.Generic;
  
      public partial class tblRoom
      {
          public tblRoom()
          {
              this.tblSections = new HashSet&lt;tblSection&gt;();
          }
  
          public int RoomNo { get; set; }
          public string Block { get; set; }
          public int Capacity { get; set; }
  
          public virtual ICollection&lt;tblSection&gt; tblSections { get; set; }
      }
  }
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>[HttpGet]
  public ActionResult editCourse()
  {
      course c = new course();
      List&lt;tblCourse&gt; data = c.editedCoursesView();
      return View("editCourse", data);    
  }
  </code></pre>
  
  <p>View: </p>
  
  <pre><code>@model List&lt;enrolmentSystem.Models.tblCourse&gt;
  @{
      ViewBag.Title = "editCourse";
  
  }
  
  &lt;h2&gt;Edit Course&lt;/h2&gt;
  &lt;table border="1"&gt;
      &lt;tr style="text-align:center;"&gt;
          &lt;td&gt;Course ID&lt;/td&gt;
          &lt;td&gt;Course Name&lt;/td&gt;
          &lt;td&gt; Course Department ID&lt;/td&gt;
          &lt;td&gt; Course Teacher ID&lt;/td&gt;
          &lt;td&gt; Course CreditHours&lt;/td&gt;
          &lt;td&gt; Course StartTime&lt;/td&gt;
          &lt;td&gt; Course EndTime&lt;/td&gt;
          &lt;td&gt; MaxCapacity &lt;/td&gt;
          &lt;td&gt; Course RoomNo &lt;/td&gt;
  
  
      &lt;/tr&gt;
      @if (Model != null)
      {
  
          foreach (var i in Model)
          {
              &lt;form action="~/Enrolment/editCourse" method="post"&gt;
                  &lt;tr&gt;
  
  
                      &lt;td&gt;@i.CourseId &lt;input name="id" type="hidden" value="@i.CourseId" /&gt; &lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="name" value="@i.CourseName" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="dpId" value="@i.departmentID" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="teacherId" value="@i.TeacherId" required /&gt;&lt;/td&gt;
  
  
                      &lt;td&gt;&lt;input type="number" name="creditHours" value="@i.CreditHours" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="startTime" value="@i.tblSection.startTime" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="endTime" value="@i.tblSection.endTime" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="capacity" value="@i.tblSection.tblRoom.Capacity" required /&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="number" name="roomNo" value="@i.tblSection.RoomNo" required /&gt;&lt;/td&gt;
                      &lt;td&gt;  &lt;input type="submit" value="Update Course" /&gt; &lt;/td&gt;
  
  
                  &lt;/tr&gt;
              &lt;/form&gt;
          }
      }
  &lt;/table&gt;
  </code></pre>