title: Bind value of Foreign Key to Datagrid (WPF / EF)
body: <p>This will be my first project with MVVM and EF..
  I have seen some answers, but it is still not clear to me.</p>
  
  <p>I generated an EF model from a Database. In this database :</p>
  
  <p>1) table Crew with property RankId as foreign key to table Rank</p>
  
  <p>2) table Rank</p>
  
  <p>In my CrewListView is a datagrid populated with List</p>
  
  <p>How can I get the name of the Rank in this datagrid instead of the Id??</p>
  
  <p>View:
          <br>
              
                  
                  
                  </p>
  
  <pre><code>            &lt;--This does (offcourse) not work --&gt;
              &lt;DataGridTextColumn Header="Rank" Binding="{Binding RankName}" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>
  
  <p>ViewModel:
          private IList _crew;</p>
  
  <pre><code>    public IList&lt;Crew&gt; AllCrew
      {
          get
          {
              if (_crew == null)
              {
                  GetCrew();
              }
              return _crew;
          }
      }
  
      private void GetCrew()
      {
          using (var crewrepo = new CrewRepository())
          {
              _crew = crewrepo.GetAll();
          }
      }
  </code></pre>