title: Onion Architecture Identity Framework
body: <p>I am following <a href="http://jeffreypalermo.com/blog/the-onion-architecture-part-1/" rel="noreferrer">Onion Architecture</a>. And in that I am using ASP.NET Identity Framework. </p>
  
  <p>Here is my Project Structure:</p>
  
  <pre><code>1-Core
       - Domain Classes //It contains my T4 template classes
            -- AppUser  //It is Identity User.  
       - Repository Interfaces
       - Service Interfaces
  2-Infrastructure
       - Data //It contains my edmx file, I am using Db First approach.
       - Dependency Injection
       - Repository Interfaces Implementation
       - Service Interfaces Implementation
  3-WebApi
       - Web Api Project
  4-WebClient
       - My AngularJs App
  5-Test
       - Test Project
  </code></pre>
  
  <p>I have copied the scripts of the ASP.NET Identity tables and executed on my SQL Server. Which created Identity Tables for me.</p>
  
  <p>In my <code>Infrastructure.Data</code> project, I created an <code>Edmx File</code> and inserted Identity tables in it. Then I moved my <code>T4 template</code> to <code>Core.Domain</code>, here I created <code>Partial Class</code> for my <code>AppUser</code> and other Identity tables.</p>
  
  <pre><code>// This make my Core.Domain project dependent on `Microsoft.AspNet.Identity`
  // Which is a violation. 
  public partial class AppUser : IdentityUser 
  {
      //My Custom Properties
  }
  </code></pre>
  
  <p>Now I have confusion about my <code>AppUser</code> Class which is in Core. According to the Onion Architecture standards, This whole layer should not a be dependent on any external library. But here I am using 'Microsoft.AspNet.Identity' in order to make my user as Identity User. Is there any solution for that?</p>