小编use*_*360的帖子

EF:无法确定类型之间关联的主要终点

无法确定类型之间关联的主要终点。必须使用关系流利的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; }
}
Run Code Online (Sandbox Code Playgroud)

` …

entity-framework

3
推荐指数
1
解决办法
1079
查看次数

标签 统计

entity-framework ×1