加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ASP.NET MVC5 EF6与ApplicationUser的关系

发布时间:2020-12-16 09:41:21 所属栏目:asp.Net 来源:网络整理
导读:[ForeignKey("Creator")]public string CreatorID {get;set;}public virtual ApplicationUser Creator {get;set;} 我有一个模型,我想保存创建者和修饰符. 但是迁移过程中存在错误 TSRDTEST.Models.IdentityUserLogin: : EntityType 'IdentityUserLogin' has
[ForeignKey("Creator")]
public string CreatorID {get;set;}
public virtual ApplicationUser Creator {get;set;}

我有一个模型,我想保存创建者和修饰符.
但是迁移过程中存在错误

TSRDTEST.Models.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.

TSRDTEST.Models.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.

IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.

IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.

我正在使用内置的登录/注销/注册模板,数据库列前缀为“AspNet”,有没有办法修复该错误而无需修改整个项目项目并保留带有前缀AspNet的列,谢谢

解决方法

其实我不明白你想做什么.但是实体之间的映射应该是这样的.

public string CreatorID {get;set;}
    [ForeignKey("CreatorID ")]
    public virtual ApplicationUser Creator {get;set;}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读