重命名ASP.NET身份表时,重复的外键 [英] Duplicate foreign keys when renaming ASP.NET Identity tables

查看:156
本文介绍了重命名ASP.NET身份表时,重复的外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着<一个忠告href=\"http://stackoverflow.com/questions/19460386/how-can-i-change-the-table-names-when-using-visual-studio-2013-aspnet-identity\">this问题重命名我的ASP.NET标识表:

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");

不过,这将导致两个属性为UserClaim到用户的关系 - 用户ID IdentityUser_Id

有没有什么办法可以解决这个问题?

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");

希望有所帮助。

这篇关于重命名ASP.NET身份表时,重复的外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆