这个问题在这里已有答案:
我正在使用实体框架核心 . 我想要3个表:Appoitments,Users和Roles . “用户”表包含具有不同角色的应用程序成员 . 有没有办法让'Appoitments'表与外键:ClientID和'User'类型的ConsultantID?
public class ApplicationUser : IdentityUser
{
public List<Appointment> Appointments { get; set; }
}
public class Appointment
{
public int AppointmentId {get;set;}
public DateTime Date { get; set; }
public int RoomNumber { get; set; }
public ApplicationUser ConsultantId { get; set; }
public ApplicationUser ClientId { get; set; }
}
我创建了类ApplicationUser和Appointment,并在ApplicationDbContext中添加了属性:public DbSet Appointments {get;组; } .
但是当我尝试添加迁移时,Packet Manager抛出“(无法确定”List“类型的导航属性”ApplicationUser.Appointments“所代表的关系 .
1 回答
问题中没有足够的信息来区分发生了什么......但是我不知道't see why something like this wouldn'工作: