title: System.ObjectDisposedException when trying to receive the data from a List
body: <p>Hello I am writing an ASP.Net MVC application and I have a special class dedicated for Database connection. In my HomeController I call the static methods of this special DB class, which return the needed data into objects. I use the Entity Framework in order to achieve this. However I get a strange exception when I try to use the List from my Controller. I believe that the problem is that I have a virtual inner collection that is disposed after the entity framework methods are done. I can access the main-group fields, but can't access the inner Lists. Here is my model:</p>
  
  <pre><code>public partial class Teacher
  {
      public Teacher()
      {
          this.TeacherRelationships = new List&lt;TeacherRelationship&gt;();
          this.CourseTemplates = new List&lt;CourseTemplate&gt;();
          this.Orders = new List&lt;Order&gt;();
      }
  
      public int ID { get; set; }
      public string Name { get; set; }
      public string DescriptionText { get; set; }
      public Nullable&lt;int&gt; Phone { get; set; }
      public string Email { get; set; }
      public string PictureFilePath { get; set; }
      public virtual ICollection&lt;TeacherRelationship&gt; TeacherRelationships { get; set; }
      public virtual ICollection&lt;CourseTemplate&gt; CourseTemplates { get; set; }
      public virtual ICollection&lt;Order&gt; Orders { get; set; }
  }
  </code></pre>
  
  <p>When I try to get the CourseTemplate results I get this exception:</p>
  
  <blockquote>
    <p>Exception Details: System.ObjectDisposedException: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.</p>
  </blockquote>
  
  <p>I tried to investigate it alone, but everything I found is the suggestion to return a List instead of a query. Here is also the code for my DBConnection method:</p>
  
  <pre><code>    public static List&lt;Teacher&gt; returnAllTeachers()
      {
          using (var db = new Context())
          {
              var query = from th in db.Teachers
                          select th;
  
              return query.ToList();
          }
      }
  </code></pre>
  
  <p>What am I doing wrong?</p>