【发布时间】:2019-03-11 09:41:34
【问题描述】:
我有两个班级:
public class User
{
public Guid UserId { get; set; }
[Required]
public string Username { get; set; }
[Required]
public string Password { get; set; }
public UserProfile UserProfile { get; set; }
}
public class UserProfile
{
public int UserProfileId { get; set; }
public string Avatar { get; set; }
public User User { get; set; }
public User Wingman { get; set; }
}
尝试添加迁移可以理解,但出现以下错误:
无法确定导航所代表的关系 “UserProfile”类型的属性“User.UserProfile”。要么手动 配置关系,或使用 '[NotMapped]' 属性或使用 'EntityTypeBuilder.Ignore' 'OnModelCreating'。
UserProfile.User 是用户本身,UserProfile.Wingman 是另一个用户,代表僚机。
我需要另一张桌子,比如一座桥,还是有其他方法可以解决这个问题?
而且我不需要从User 中引用Wingman。
提前致谢!
【问题讨论】:
标签: c# asp.net-core ef-code-first entity-framework-core