【发布时间】:2015-07-21 02:25:24
【问题描述】:
[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 的列,谢谢
【问题讨论】:
-
这几乎读起来像俳句。您能否重新表述问题以使其更具可读性?
-
已更新,请您再看一遍,谢谢。
-
你有两个 DbContext 吗?例如
ApplicationContext(默认情况下在您创建 ASP.NET MVC 项目时存在)和您创建的另一个 DbContext。 -
公共类 ApplicationDbContext : IdentityDbContext
,公共类 DefaultConnection : DbContext 二,对!
标签: asp.net-mvc entity-framework asp.net-mvc-5 entity-framework-6 asp.net-identity-2