【发布时间】:2015-01-19 16:48:24
【问题描述】:
无法确定类型之间关联的主体端。此关联的主体端必须使用关系流式 API 或数据注释显式配置。
型号:
`
[Table("Employees")]
public class Employee : Entity
{
public string Name { get; set; }
public int? AbsenceId { get; set; }
[ForeignKey("AbsenceId")]
public virtual Absence Absence { get; set; }
}
[Table("Absences")]
public class Absence : Entity
{
public DateTime From { get; set; }
public DateTime To { get; set; }
public string Reason { get; set; }
public int? SubstituteId { get; set; }
[ForeignKey("SubstituteId")]
public virtual Employee Substitute { get; set; }
}
`
员工缺勤,其员工可能与提及缺勤的员工不同。
这种情况有什么解决办法吗?
【问题讨论】:
标签: entity-framework