title: MVC 4 How to display foreign key related data in view?
body: <p>I have two classes generated from my database by EF 6:</p>
  
  <pre><code>class Person {
      public int PID { set; get; }
      public string Name { set; get; }
      public int CountryID { set; get; }
  
      public virtual ICollection&lt;Country&gt; Country { set; get;}
  }
  
  class Country {
      public int CID { set; get; }
      public string Name { set; get; }
  }
  </code></pre>
  
  <p>I would like to show data in a table as follows:</p>
  
  <pre><code>Person Name ^v                 Countries ^v                 Operation
  ----------------------------- ----------------------------- ---------------
  [___________________________] [________dropdown_________|v] [Edit] [Delete]
  ...
  [___________________________] [________dropdown_________|v] [Edit] [Delete]
  [Pager]
  </code></pre>
  
  <p>In my database <em>CountryID</em> is a foreign key to <em>Country.CID</em>. I would like to show data and allow to in line editing and/or deleting. The columns have to be disabled but in edit mode of course enabled instead.<br>
  I googled a lot and read <em>stackoverflow</em> too but didn't found a comprehensive help for this. </p>
  
  <p>Does anybody has an example how to do this gridview?<br>
  Thanks a lot</p>