ASP.NET Identity - Error when changing User ID Primary Key default type from string to int AND when using custom table names

后端 未结 1 1826
故里飘歌
故里飘歌 2021-02-09 06:18

I\'m using Microsoft.AspNet.Identity 2.0.0-beta1 and Entity Framework 6.1.0-beta1 (released 11 Feb 2014).

I\'m getting the following error when I try to change the defa

1条回答
  •  醉梦人生
    2021-02-09 06:45

    I think the mapping might be incorrect. While defining the ApplicationDbContext class, you are using the custom classes defined for roles, logins and claims for generic but passing the base classes for mapping the tables. For the ChangePK example the following mapping worked for me. Let me know if this works for you too. The mapping should be simple enough

       protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
    
            modelBuilder.Entity().ToTable("MyUsers");
            modelBuilder.Entity().ToTable("MyUserRoles");
            modelBuilder.Entity().ToTable("MyUserLogins");
            modelBuilder.Entity().ToTable("MyUserClaims");
            modelBuilder.Entity().ToTable("MyRoles");
        }
    

    0 讨论(0)
提交回复
热议问题