MVC accessing linked table value using entity framework
<p>I am new to entity framework and I am trying to get my head around it.  I am used to writing stored procedures which have all the data I need on a example by example basis.</p>

<p>I am under the impression that I can get all values from a particular table including the foreign key values direct using entity framework without having to write a select query which joins the data.</p>

<p>I have the following in my controller</p>

<pre><code>    public ActionResult Patient()
    {
        using (var context = new WaysToWellnessDB())
        {
            var patients = context.Patients.ToList();
            return View(patients);
        }
    }
</code></pre>

<p>In my view I have the following</p>

<pre><code>@foreach (var item in Model)
{
    &lt;p&gt;
        @item.FirstName @item.Surname @item.Gender.GenderDesc
    &lt;/p&gt;
}
</code></pre>

<p>I have two tables, Patient and Gender, GenderId is a foreign key which I am trying to get the GenderDesc from that table.</p>

<p>I am getting the following message</p>

<blockquote>
  <p>The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.</p>
</blockquote>

<p>Can someone explain why I cannot access GenderDesc.  It does work if I remove the using() around my context, but I don't really want to leave that open, is there a way to get this to work still having the using around?</p>

<p>Thanks in advance.</p>