属性不是导航属性

时间:2019-02-01 11:15:11

标签: c# asp.net-core-2.1 ef-core-2.1

我正在尝试使用ExitDetailAdminEntityefcore的退出详细信息中访问批准状态,但这表明该属性不是导航属性

public class ExitDetailEntity : Entity
{
    public EmployeeDetailEntity EmployeeDetail { get; set; }
    public int EmployeeDetailId { get; set; }

    public ExitProfileCardStatusEnum ProfileStatus { get; set; }

    public ExitRequestStatusEnum RequestStatus { get; set; }

    public ExitStatusEnum ApprovalStatus { get; set; }

    public ExitDetailAdminEntity ExitDetailAdmin { get; set; }

    public ExitDetailFinanceEntity ExitDetailFinance { get; set; }

    public ExitDetailHREntity ExitDetailHR { get; set; }

    public ExitDetailITAdminEntity ExitDetailITAdmin { get; set; }

    public ExitDetailManagerEntity ExitDetailManager { get; set; }
}

这是ExitDetailAdmin类

[Table("ExitDetail_Admin")]
public class ExitDetailAdminEntity : Entity`enter code here`
{
    public EmployeeDetailEntity EmployeeDetail { get; set; }
    public int EmployeeDetailId { get; set; }

    public ExitRequestStatusEnum RequestStatus { get; set; }

    public bool VisitingCardSubmitted { get; set; }

    public bool MobileDeactivation { get; set; }

    public bool PendingReimburshment { get; set; }

    public ExitApprovalStatusEnum AdminApprovalStatus { get; set; }

    [Column(TypeName = "date")]
    public DateTime? ApprovedDate { get; set; }

    public string ApprovedBy { get; set; }

    public ExitDetailEntity ExitDetail { get; set; }
    public int? ExitDetailId { get; set; }
}

1 个答案:

答案 0 :(得分:0)

请更正 ExitDetailAdminService.cs 中的行号 39 。代码必须类似于:

_portalDbContext.
.ExitDetailByAdmin
.Indclude(x=> x.EmployeeDetail)
.Include(x=> x.ExitDetail)

Include()方法允许加载相关实体,例如在您的情况下,EmployeeDetail,ExitDetail。但是 ApprovalStatus 是一个枚举,而不是一个实体。