title: DB-First authentication confusion with ASP.NET Web API 2 + EF6
body: <p>I need to create a Web API C# application for an existing MySQL database. I've managed to use Entity Framework 6 to bind every database table to a RESTful API <em>(that allows CRUD operations)</em>.</p>
  
  <p>I want to implement a login/registration system <em>(so that I can implement roles and permissions in the future, and restrict certain API requests)</em>.</p>
  
  <p>The MySQL database I have to use has a table for users <em>(called <code>user</code>)</em> that has the following self-explanatory columns:</p>
  
  <ul>
  <li><code>id</code></li>
  <li><code>email</code></li>
  <li><code>username</code></li>
  <li><code>password_hash</code></li>
  </ul>
  
  <p>It seems that the de-facto standard for authentication is ASP.Net Identity. I have spent the last hour trying to figure out how to make Identity work with an existing DB-First Entity Framework setup.</p>
  
  <p>If I try to construct <code>ApplicationUser</code> instances storing <code>user</code> instances <em>(entities from the MySQL database)</em> to retrieve user data, I get the following error:</p>
  
  <blockquote>
    <p>The entity type ApplicationUser is not part of the model for the current context.</p>
  </blockquote>
  
  <p>I assume I need to store Identity data in my MySQL database, but couldn't find any resource on how to do that. I've tried completely removing the <code>ApplicationUser</code> class and making my <code>user</code> entity class derive from <code>IdentityUser</code>, but calling <code>UserManager.CreateAsync</code> resulted in LINQ to Entities conversion errors.</p>
  
  <p><strong>How do I setup authentication in a Web API 2 application, having an existing <code>user</code> entity?</strong></p>