[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,谢谢
答案 0 :(得分:1)
其实我不明白你想做什么。但是实体之间的映射应该是这样的。
public string CreatorID {get;set;}
[ForeignKey("CreatorID ")]
public virtual ApplicationUser Creator {get;set;}