title: ASP.NET Identity - Error when changing User ID Primary Key default type from string to int AND when using custom table names
body: <p>I'm using Microsoft.AspNet.Identity 2.0.0-beta1 and Entity Framework 6.1.0-beta1 (released 11 Feb 2014). </p>
  
  <p>I'm getting the following error when I try to change the default type of User ID Primary Key from string to int <strong>AND</strong> when I try to use custom table names (so User.MyUsers instead of dbo.AspNetUsers): </p>
  
  <p>"<em>The entity types 'IdentityUser' and 'ApplicationUser' cannot share table 'MyUsers' because they are not in the same type hierarchy or do not have a valid one to one foreign key relationship with matching primary keys between them.</em>"</p>
  
  <p>I can successfully change the default type of User ID PK from string to int OR change the default identity table names but I cannot do both <strong>together</strong> without hitting this error.</p>
  
  <p>My solution is based on:</p>
  
  <p>1: Section "Make the type of Primary Key be extensible for Users and Roles" from <a href="http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx</a>. </p>
  
  <p>2: <a href="https://stackoverflow.com/questions/19460386/how-can-i-change-the-table-names-when-using-visual-studio-2013-aspnet-identity">How can I change the table names when using Visual Studio 2013 ASP.NET Identity?</a>. </p>
  
  <p>My actual code is:</p>
  
  <pre><code>using Microsoft.AspNet.Identity.EntityFramework;
  
  namespace Musetone.Models
  {
  public class ApplicationUser : IdentityUser&lt;int, CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  {
  }
  
  public class CustomRole : IdentityRole&lt;int, CustomUserRole&gt;
  {
      public CustomRole() { }
      public CustomRole(string name) { Name = name; }
  }
  
  public class CustomUserRole : IdentityUserRole&lt;int&gt; { }
  public class CustomUserClaim : IdentityUserClaim&lt;int&gt; { }
  public class CustomUserLogin : IdentityUserLogin&lt;int&gt; { }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  {
      public ApplicationDbContext()
          : base("DefaultConnection")
      {
      }
  
      protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
  
          modelBuilder.Entity&lt;IdentityUser&gt;().ToTable("MyUsers", "User").HasKey(u =&gt; u.Id).Property(u =&gt; u.Id).HasColumnType("int");
          modelBuilder.Entity&lt;ApplicationUser&gt;().ToTable("MyUsers", "User").HasKey(u =&gt; u.Id).Property(u =&gt; u.Id).HasColumnType("int");
          modelBuilder.Entity&lt;IdentityUserRole&gt;().ToTable("MyUserRoles", "User").HasKey(r =&gt; new { r.RoleId, r.UserId }).Property(r =&gt; r.UserId).HasColumnType("int");
          modelBuilder.Entity&lt;IdentityUserLogin&gt;().ToTable("MyUserLogins", "User").HasKey(l =&gt; new { l.UserId, l.LoginProvider, l.ProviderKey }).Property(l =&gt; l.UserId).HasColumnType("int"); 
          modelBuilder.Entity&lt;IdentityUserClaim&gt;().ToTable("MyUserClaims", "User").Property(c =&gt; c.UserId).HasColumnType("int"); 
          modelBuilder.Entity&lt;IdentityRole&gt;().ToTable("MyRoles", "User").HasKey(r =&gt; r.Id); 
      }
  }
  }
  </code></pre>
  
  <p>I get this error even if I remove HasColumnType("int").</p>
  
  <p>Any help would be greatly appreciated.</p>