Reputation: 1337
I am trying to implement ASP.NET Core Identity in my MySQL database. I want to save claims in table named different that "aspnetuserclaims". I managed to point custom tables for users using this in my OnModelCreating() method in MyContext which inherits from IdentityDbContext class:
modelBuilder.Entity<ApplicationUser>().ToTable("users").Property(p => p.Id).HasColumnName("Id");
But, when I want to do the same with my class which inherits form IdentityUserClaim using:
modelBuilder.Entity<ApplicationUserClaim>().ToTable("userclaims").Property(p => p.Id).HasColumnName("Id");
It doesn't work at all.
Both ApplicationUser and ApplicationUserClaim are clean class looking like this:
public class ApplicationUser : IdentityUser<string> {}
Exception:
MySqlException: Table 'dbname.aspnetuserclaims' doesn't exist
Upvotes: 0
Views: 711
Reputation: 239290
IdentityUser
has generic type overloads. You're using IdentityUser<TKey>
, but if you want to customize something like the claim class, you need to specify IdentityUser<TKey,TUserClaim,TUserRole,TUserLogin>
.
Additionally, IdentityDbContext
also has generic type overloads, so likewise, you need to ensure you're using the correct overload there, namely: IdentityDbContext<TUser,TRole,TKey,TUserClaim,TUserRole,TUserLogin,TRoleClaim,TUserToken>
.
Upvotes: 1