Reputation: 5078
Why do I get this error: "Using the generic type 'IdentityUserRole' requires 1 type arguments" when trying to rename the tables created using Identity. Please see my code below:
protected override void OnModelCreating(ModelBuilder modelBuilder){
base.OnModelCreating(modelBuilder);
//AspNetUsers -> User
modelBuilder.Entity<AppUser>()
.ToTable("User");
//AspNetRoles -> Role
modelBuilder.Entity<IdentityRole>()
.ToTable("Role");
//AspNetUserRoles -> UserRole
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
//AspNetUserClaims -> UserClaim
modelBuilder.Entity<IdentityUserClaim>()
.ToTable("UserClaim");
//AspNetUserLogins -> UserLogin
modelBuilder.Entity<IdentityUserLogin>()
.ToTable("UserLogin");
}
I do not get any error on the Entity AppUser and Entity IdentityRole but on the rest, I get the error. Please see image below:
Upvotes: 5
Views: 2829
Reputation: 1749
The problem is that IdentityUserRole, IdentityuserClaim and IdentityuserLogin are generic classes too. Because the key for this table is specified by the generic type.
This is from the documentation
And the implementation
So you have to do the following for example:
modelBuilder.Entity<IdentityUserLogin<string>>().ToTable("UserLogin");
I hope this help you.
Upvotes: 10