title: Extend ApplicationUser how to set correctly relationship from shared project
body: <p>I am using ASP.NET Identity 2.0. Currently I would like to extend <code>ApplicationUser</code> (renamed <code>AspNetUsers</code> to <code>Users</code>) by table <code>UserDetails</code> like <code>FirstName</code> etc.</p>
  
  <p>What's my issue?
  I have separated class library project which stores EF Model. I don't like to generate another EF Model (if its not necessary).</p>
  
  <p>I have in SQL Server relationship between Users table and <code>UserDetails</code> table, that's all alright. Unfortunately in ASP project Users table is somewhere deep hard-coded in <code>IdentityUser</code>. That means I have <code>ApplicationUser</code> which inherits <code>IdentityUser</code>.</p>
  
  <p>What am I trying is in <code>AppDbContext</code>:</p>
  
  <pre><code>protected override void OnModelCreating(ModelBuilder builder)
  {
      base.OnModelCreating(builder);
  
      // Ignore columns
      builder.Entity&lt;ApplicationUser&gt;().Ignore(c =&gt; c.PhoneNumberConfirmed);
  
      // Rename tables
      builder.Entity&lt;ApplicationUser&gt;().ToTable("Users");
      builder.Entity&lt;IdentityRole&gt;().ToTable("Roles");
      builder.Entity&lt;IdentityRoleClaim&lt;string&gt;&gt;().ToTable("IdentityRoleClaims");
      builder.Entity&lt;IdentityUserClaim&lt;string&gt;&gt;().ToTable("IdentityUserClaims");
      builder.Entity&lt;IdentityUserLogin&lt;string&gt;&gt;().ToTable("IdentityUserLogins");
      builder.Entity&lt;IdentityUserToken&lt;string&gt;&gt;().ToTable("IdentityUserTokens");
  
      // Relationship
      builder.Entity&lt;ApplicationUser&gt;()
          .HasOne(p =&gt; p.UserDetails)
          .WithOne(i =&gt; i.Users)
          .HasForeignKey&lt;Shared.Database.UserDetails&gt;(u =&gt; u.UserID);
  }
  </code></pre>
  
  <p>Problem is on last line in <code>WithOne(i =&gt; i.Users)</code>, <code>i.Users</code> is not <code>ApplicationUser</code>. Funny thing is that <code>ApplicationUser</code> has same properties like <code>i.Users</code> :D</p>
  
  <p>So I only need to know how to correctly convert it to make relationship.</p>
  
  <p>Any ideas how to solve this? Or any advice how to do it another way?</p>
  
  <p>Shared project is used by 1 additional project (WCF) so I can't put there inheriting from <code>IdentityUser</code> :/</p>
  
  <p>Thanks guys.</p>