title: The ObjectContext instance has been disposed - Winforms Entity Framework
body: <p>I am trying to solve this problem and did read content regarding this error but was unable to figure out a solution.
  I am building a winforms application using Entity framework for a simple Products Categories scenario.
  Here is a snapshot of my model.
  <img src="https://i.stack.imgur.com/kKs5T.png" alt="Edmx"></p>
  
  <p>The code in ProductService class that retrieves all the products is</p>
  
  <pre><code>public static List&lt;Product&gt; GetAllProducts()
  {
      List&lt;Product&gt; products = new List&lt;Product&gt;();
      using (var entity = new SUIMSEntities1())
      {
          products = (from p in entity.Products
                      select p).ToList();
          return products;
      }            
  }
  </code></pre>
  
  <p>Code in the Products code behind is</p>
  
  <pre><code>List&lt;Product&gt; prods=ProductServices.GetAllProducts();
  dgvProducts.DataSource = prods;
  </code></pre>
  
  <p>When I try to load the Products in datagridview, the following error is shown:
  <img src="https://i.stack.imgur.com/6Lxyb.png" alt="enter image description here"></p>
  
  <p>Could you please tell me what is causing the problem?</p>
  
  <p><strong>Edit:</strong>
  The Include did the trick and in this specific scenario I changed the GetAllProducts() as below</p>
  
  <pre><code>        public static List&lt;Product&gt; GetAllProducts()
          {
              using (var entity = new SUIMSEntities1())
              {
                  List&lt;Product&gt; products = entity.Products.Include("Category").ToList();
                  return products;                
              }            
          }
  </code></pre>