我已经搜索了自己的模型与Code First
中现有授权模型之间的关联帮助。但没有找到什么对我有帮助。 (例如,尝试this)。
我的确切问题:
我有一个包含实体added_from
或last_edited_from
的模型,并希望设置对用户ID的引用。我以不同的方式尝试过它。
对我来说最合乎逻辑的方式是:
public class aTable
{
[...]
[ForeignKey("last_edited_from")]
public ApplicationUser userFK { get; set; }
public string last_edited_from { get; set; }
}

但是当我尝试这个时,我在Package Manager控制台中遇到了以下错误(" add-migration"之后)
MyProj.DAL.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
MyProj.DAL.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.