title: .net Identity: error trying to change string (GUID?) keys to int
body: <p>I have an application (using Identity 2.2) created in VS2015 with the example application (MVC, mvc individual authentication) , wich I modified following a tutorial to add some custom fields to the users table (using a migration to get added fields into the database). 
  Then for the rest of the tables (non-Identity ones) I am using EntityFramework database-first to generate CRUD controllers &amp; views etc. 
  So far so good, everything seems to be working nice.</p>
  
  <p>Now I am trying to modify it so that the keys for Identity tables are integers instead of GUIDs. I have followed this tutorial (with MVC update 3), 
  <a href="https://docs.microsoft.com/en-us/aspnet/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity#context" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity#context</a></p>
  
  <p>but after following the tutorial, when I build and run the solution i get this error when it tries to generate the models</p>
  
  <pre><code>One or more validation errors were detected during model generation:
  Proyecto.Models.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
  IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.
  </code></pre>
  
  <p>I have no idea how to fix it... any help is appreciated.</p>
  
  <p>my Models/IdentityModels.cs:</p>
  
  <pre><code>public class ApplicationUser : IdentityUser&lt;int, CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  
  {
      //added custom fields
      [Column(TypeName = "varchar")]
      [StringLength(50)]
      public string Nombre { get; set; }
      public DateTime FechaAlta { get; set; }
      public DateTime? FechaUltModif { get; set; }
      public bool Activo { get; set; }
      public string Notas { get; set; }
  
      public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser, int&gt; manager)
      {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
          // Add custom user claims here
          return userIdentity;
      }
  }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser, CustomRole, int, CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  {
      public ApplicationDbContext()
          : base("DefaultConnection")
      {
      }
  
      public static ApplicationDbContext Create()
      {
          return new ApplicationDbContext();
      }
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
          //to fix some conflicts using mysql
          modelBuilder.Entity&lt;ApplicationUser&gt;().Property(u =&gt; u.UserName).HasMaxLength(255);
          modelBuilder.Entity&lt;ApplicationUser&gt;().Property(u =&gt; u.Email).HasMaxLength(255);
          modelBuilder.Entity&lt;IdentityRole&gt;().Property(r =&gt; r.Name).HasMaxLength(255);
      }
  
  }
  
  
  //aded for int keys
  public class CustomUserRole : IdentityUserRole&lt;int&gt; { }
  public class CustomUserClaim : IdentityUserClaim&lt;int&gt; { }
  public class CustomUserLogin : IdentityUserLogin&lt;int&gt; { }
  public class CustomRole : IdentityRole&lt;int, CustomUserRole&gt;
  {
      public CustomRole() { }
      public CustomRole(string name) { Name = name; }
  }
  public class CustomUserStore : UserStore&lt;ApplicationUser, CustomRole, int,
      CustomUserLogin, CustomUserRole, CustomUserClaim&gt;
  {
      public CustomUserStore(ApplicationDbContext context)
          : base(context)
      {
      }
  }
  public class CustomRoleStore : RoleStore&lt;CustomRole, int, CustomUserRole&gt;
  {
      public CustomRoleStore(ApplicationDbContext context)
          : base(context)
      {
      }
  }
  </code></pre>