title: Get Latest record of table via Entity Framework
body: <p>I'm using code first feature of EntityFramework and I have created a model class with this field that have their own property (I don't mention them here!) :</p>
  
  <pre><code>public class Portrait
  {
          private Guid _id;
          private string _aboutimage;
          private string _aboutMe;
          private string _mainMenu;
          private string _headerImage;
          private string _resume;
          private string _showpiece;
          private string _siteMenu;
          private string _adminMenu;
  }
  </code></pre>
  
  <p>and for each part of this class I have separate ViewModel, for example I have <code>AboutViewModel</code> to update <code>About</code> in admin part and navigate in about page in website :</p>
  
  <pre><code>public class AboutViewModel
  {
          public Guid Id { get; set; }
          public string AboutText { get; set; }
          public string Image { get; set; }
  }
  </code></pre>
  
  <p>Now when I update the <code>AboutViewModel</code>, <code>Portrait</code> table in database will create a record that will have about text (other field will be null)</p>
  
  <p>And for updating for other part of this table like <code>Resume</code> or others, it will generate another record with updated and inserted field (now in this record about text will be null!)</p>
  
  <p>Now how can I get the about field to show it in UI as I have several records !? I don't want and also can not get these field by ID because I always want to have their latest updated to show in web site, what I have written is like this ,my about action to get the about text is like this :</p>
  
  <pre><code>public ViewResult About()
  {
              var about= _portraitRepository.GetContent();
  
              return View(about);
  }
  </code></pre>
  
  <p>and the <code>GetContent()</code> is like this :</p>
  
  <pre><code>public Portrait GetContent()
  {
              return _siteContext.Portraits.Find();
  }
  </code></pre>
  
  <p>but dosn't work and I got this error:</p>
  
  <blockquote>
    <p><em>The number of primary key values passed must match number of primary key values defined on the entity. Parameter name: keyValues</em></p>
  </blockquote>
  
  <p>Am I in a wrong direction? How can I solve this problem please?</p>