title: EF 4 not loading foreign key object
body: <p>I am running an ASP.NET MVC 3 application (C#).</p>
  
  <p>I recently made a foreign key in my database nullable. This probably isn't best practice however it is necessary for my scenario. So now when I display my report (ASPX View Engine), the values for the object which I have made nullable in my db will not display.</p>
  
  <p>The data structure now (simplified) is as follows:</p>
  
  <pre><code>Inventory
  ________________
  InventoryID int PK
  ShopID FK int NOT NULL
  ProductID FK int NULL
  </code></pre>
  
  <p>The only change to this is that ProductID used to be Not Nullable.</p>
  
  <p>My ActionResult is as follows:</p>
  
  <pre><code>[HttpPost]
  public ActionResult InventoryReport(FormCollection formVariables, InventoryReportRequest reportRequest)
          {
              ModelContainer ctn = new ModelContainer();
  
              var query = ctn.Inventory.Where(ic =&gt; !ic.Deleted &amp;&amp; ic.ShopID == reportRequest.ShopID);
  
              if (reportRequest.ProductID.HasValue)
              {
                  query = (from ic in query
                           where reportRequest.ProductID == ic.ProductID
                           select ic);
              }
  
              List&lt;Inventory&gt; checks = query.ToList();
  
              if (checks.Count &gt; 0)
              {
                  return View(checks);
              }
              else
              {
                  return RedirectToAction("Index");
              }
          }
  </code></pre>
  
  <p>When I debug though this Action, I can see that the ProductID is being retrieved, however the Product object remains null. So when I want to display my results in my view - </p>
  
  <pre><code>&lt;table class="normal" width="100%"&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  Date
              &lt;/th&gt;
              &lt;th&gt;
                  Shop
              &lt;/th&gt;
              &lt;th&gt;
                  **Product Name**
              &lt;/th&gt;
              &lt;th&gt;
                  **Product ID**
              &lt;/th&gt;
              &lt;th&gt;
                  Active
              &lt;/th&gt;
          &lt;/tr&gt;
  
      &lt;% foreach (var item in Model) { %&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;%: Html.DisplayFor(modelItem =&gt; item.DateChecked) %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: Html.DisplayFor(modelItem =&gt; item.Shop.Name) %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  **&lt;%: Html.DisplayFor(modelItem =&gt; item.Product.Name) %&gt;**
              &lt;/td&gt;
              &lt;td&gt;
                  **&lt;%: Html.DisplayFor(modelItem =&gt; item.Product.ProductID) %&gt;**
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;%: Html.DisplayFor(modelItem =&gt; item.Active) %&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;% } %&gt; 
  
      &lt;/table&gt;
  </code></pre>
  
  <p>The starred items appear blank.</p>
  
  <p>Can any offer advice as to what I need to do to resolve this issue? If more information is required please just ask :)</p>