我正在尝试为应用程序用户创建外键。我将此引用的模型不是默认上下文的一部分。这意味着我的所有用户数据都在另一个数据库中。这似乎给我带来了一些问题。
我的模型看起来像这样
public class ThreadModel
{
[Key]
public Guid ThreadId { get; set; }
public int Index { get; set; }
public String Title { get; set; }
public String Description { get; set; }
public virtual PostModel LatestPost { get; set; }
public virtual List<SubThreadModel> SubThreads { get; set; }
}
public class SubThreadModel
{
[Key]
public Guid SubThreadId { get; set; }
public String Title { get; set; }
public bool IsPinned { get; set; }
public bool IsLocked { get; set; }
public virtual ApplicationUser Creator { get; set; }
public DateTime TimeCreated { get; set; }
public virtual PostModel LatestPost { get; set; }
public virtual List<PostModel> Posts { get; set; }
}
public class PostModel
{
[Key]
public Guid PostId { get; set; }
public virtual SubThreadModel Topic { get; set; }
public virtual ApplicationUser Creator { get; set; }
public DateTime TimeCreated { get; set; }
public DateTime TimeEdited { get; set; }
public bool IsRemoved { get; set; }
public String Text { get; set; }
public virtual List<PostLikeModel> Likes { get; set; }
}
我得到的错误是:
MyPage.Models.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
MyPage.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.