【发布时间】:2014-02-18 09:36:52
【问题描述】:
这是我的两个模型,我在更新数据库时在 asp.net mvc5 codefirst 上收到此错误
错误:无法确定类型“ModulericaV1.Areas.Hr.Models.HrDepartment”和“ModulericaV1.Areas.Hr.Models.HrPerson”之间关联的主体端。此关联的主体端必须使用关系流式 API 或数据注释显式配置。
部门
public class HrDepartment
{
[Key]
public int Id { get; set; }
[Display(Name = "Departman Adı")]
public string Name { get; set; }
public int? HrDepartmentId { get; set; }
[ForeignKey("HrDepartmentId")]
public virtual HrDepartment RelatedDepartment { get; set; }
public int HrPersonId { get; set; }
public virtual HrPerson HrPerson { get; set; }
}
人
public class HrPerson
{
public int Id { get; set; }
[Display(Name = "Ad")]
public string Name { get; set; }
[Display(Name = "Departman")]
public int HrDepartmentId { get; set; }
public virtual HrDepartment HrDepartment { get; set; }
}
【问题讨论】:
标签: asp.net-mvc data-annotations code-first