title: Select specific columns using EF in MVC 5
body: <p>I want to get some specific column values using <code>Entity Framework</code> in MVC 5. But it's showing me error. Here is my code for controller method:</p>
  
  <pre><code>public ActionResult Index()
  {
      var systemUsers = db.SystemUsers
                          .Include(s =&gt; s.SystemUser1)
                          .Select(s =&gt; new {
                                            s.FullName, 
                                            s.Email, 
                                            s.Image, 
                                            s.UpdateDate, 
                                            s.UpdatedBy, 
                                            s.Id
                                   });
      return View(systemUsers.ToList());
  }
  </code></pre>
  
  <p>This is the error message:</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'System.Collections.Generic.List<code>1[&lt;&gt;f__AnonymousType1</code>6[System.String,System.String,System.String,System.Nullable<code>1[System.DateTime],System.Nullable</code>1[System.Int32],System.Int32]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MVC.Models.SystemUser]'.</p>
  </blockquote>
  
  <p>Again when I'm unable to get single result with specific columns. By default controller method also returning unexpected foreign key data while trying to get using <code>ajax</code>. 
  Here is the code for single result.</p>
  
  <pre><code>[HttpPost]
  public ActionResult Details(int? id)
  {
      if (id == null)
      {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
      }
      SystemUser systemUser = db.SystemUsers.Find(id);
      return Json(systemUser);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/a2qUb.png" rel="nofollow noreferrer">Here is the result in console</a></p>