title: Error displaying details (ObjectContext instance has been disposed)
body: <p>I'm building an ASP.NET MVC 3 app and I've got a model that looks something like so:</p>
  
  <pre><code>public partial class Flavor
  {
     // ...
     public string Name { get; set; }
     public bool HasNuts {get; set; }
     public virtual ICollection&lt;SaleData&gt; Sales {get; set;}
     // ...
  }
  </code></pre>
  
  <p>which retrieves some data from a db as such:</p>
  
  <pre><code>public PartialViewResult Details(int id)
  {
     using (var db = new IceCreamDBFlavors())
     {
        Flavor someFlavor = db.Flavors.Find(id);
        someFlavor.Sales = db.Sales.Where(c =&gt; c.FlavorID == id).ToList();
        return PartialView("details", someFlavor);      
     }
  }
  </code></pre>
  
  <p>over on the view I do something like this:</p>
  
  <pre><code>&lt;fieldset&gt;
     &lt;legend&gt;Sales Data&lt;/legend&gt;
     @foreach (var sale in Model.Sales)
     {
        &lt;div&gt;Weekly&lt;/div&gt;
        &lt;div&gt;@sale.Weekly&lt;/div&gt;
     }
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>If I don't retrieve the Sales data, my Flavor data displays fine with no errors, but adding the call to retrieve the list of sales data causes an error <strong>"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."</strong> to occur.</p>
  
  <p>I've read a few other posts about this and guess I'm missing something here.  I believe this error happens due to lazy loading, at least based on what I've read here and elsewhere.  Setting a breakpoint in the Controller before returning the PartialView and checking the object, I believe, causes the evaluation to take place, so everything displays as I would want.</p>
  
  <p>I was under the impression that the <code>ToList()</code> call would force the Sales collection to be filled in.  Since I don't have the issue when that line's commented out, I assume the problem is still related to that and when the View is attempting to iterate the Sales, it can't.  Am I correct here?  I guess I <em>thought</em> I was forcing the evaluation.  How do I resolve this?</p>