title: Entity framework - objectcontext disposed exception
body: <p>I've been debugging this program without any result, and unfortunately I can't see the root of the problem. I get this exception: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.</p>
  
  <p>There are 2 tables:
  - CustomerSet
  - OrderSet</p>
  
  <p>A field named Customer_id in the Orders table ensures the relationship between the tables, and there is a virtual navigation property called Customer in the Orders table as well.</p>
  
  <p>The scenario is the following:
  I insert an element into the Orders table:</p>
  
  <pre><code>Order order = new Order();
  Order.order_id = GenerateId(IdType.Order);
  Order.date = DateTime.Now;
  Order.Customer_id = GetCustomerId(tbCustomerName.Text);
  Insert(order);
  </code></pre>
  
  <p>Within the Insert method there is DBContext in a using statement, so it automatically dispose when needed. I work inside this.</p>
  
  <p>After that, I need data from the previously inserted element (for instance, I need some property of the Customer field).
  And now I'm hoping that the Customer field got value:</p>
  
  <pre><code>Order o = GetOrder(order.order_id);
  </code></pre>
  
  <p>And I got this o with an exception in the Customer field: o.Customer threw an exception of type 'System.ObjectDisposedException'</p>
  
  <p>I was playing with lazy loading, turning it on or off, but I didn't work out. The situation is the same...</p>
  
  <p>What do I make a mess with?</p>
  
  <p>What is real nice in this, that if I go step-by-step with F11, it often works correctly!</p>
  
  <p>Please help! Thank you in advance.</p>