title: ASP.NET MVC 5 - Identity. How to get current ApplicationUser
body: <p>I have an Article entity in my project which has the <code>ApplicationUser</code> property named <code>Author</code>. How can I get the full object of currently logged <code>ApplicationUser</code>? While creating a new article, I have to set the <code>Author</code> property in <code>Article</code> to the current <code>ApplicationUser</code>.</p>
  
  <p>In the old Membership mechanism it was simple, but in the new Identity approach I don't know how to do this.</p>
  
  <p>I tried to do it this way:</p>
  
  <ul>
  <li>Add using statement for Identity extensions: <code>using Microsoft.AspNet.Identity;</code></li>
  <li>Then I try to get the current user: <code>ApplicationUser currentUser = db.Users.FirstOrDefault(x =&gt; x.Id == User.Identity.GetUserId());</code></li>
  </ul>
  
  <p>But I get the following exception:</p>
  
  <blockquote>
    <p>LINQ to Entities does not recognize the method 'System.String GetUserId(System.Security.Principal.IIdentity)' method, and this method cannot be translated into a store expression.
      Source=EntityFramework</p>
  </blockquote>