سؤال

I followed the advice in this question to rename my ASP.NET Identity tables:

modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaim");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin");
modelBuilder.Entity<IdentityRole>().ToTable("Role");
modelBuilder.Entity<IdentityUser>().ToTable("User");
modelBuilder.Entity<ApplicationUser>().ToTable("User");

However this results in two properties for the UserClaim to User relation - UserId and IdentityUser_Id:

enter image description here

Is there any way I can fix this?

هل كانت مفيدة؟

المحلول

You should skip the following line, then it works perfectly well:

modelBuilder.Entity<IdentityUser>().ToTable("User");

So the only mapping you need is:

modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaim");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin");
modelBuilder.Entity<IdentityRole>().ToTable("Role");
modelBuilder.Entity<ApplicationUser>().ToTable("User");

Hope that helps.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top