我有一个感兴趣的表达形式,它使用以下模型
public class dsExpressionOfInterest
{
public int dsExpressionOfInterestID { get; set; }
[Required(ErrorMessage = "Please enter a Date")]
[DataType(DataType.Date)]
[Display(Name = "Date")]
public DateTime Date { get; set; }
[Required(ErrorMessage = "Please enter the Contact Person")]
[Display(Name = "Contact Person")]
public string ContactPerson { get; set; }
[Required(ErrorMessage = "Please enter the Telephone Number")]
[Display(Name = "Telephone")]
public string Telephone { get; set; }
[Required(ErrorMessage = "Please enter the nature of the query")]
[Display(Name = "Nature of query")]
public string NatureOfQuery { get; set; }
public virtual dsRegistration dsRegistration { get; set; }
}
我还有注册表格,其中包含以下型号
public class dsRegistration
{
public int dsRegistrationID { get; set; }
public int dsExpressionOfInterestID { get; set; }
[Display(Name = "SLA")]
public bool SLAReceived { get; set; }
[DataType(DataType.Date)]
[Display(Name = "Date Received")]
public DateTime? SLAReceivedDate { get; set; }
public virtual dsExpressionOfInterest dsExpressionOfInterest { get; set; }
}
我的问题是我不确定如何设置这两个模型之间的关系。 在创建注册记录之前,您必须在表达兴趣表中有一条记录。
我收到错误的那一刻
Unable to determine the principal end of an association between the types
实际上它是dsExpressionOfInterestID
上的一对一关系我是否需要使用数据注释,如果是这样,有人能指出我正确的方向吗?
答案 0 :(得分:0)
我认为问题在于,不清楚父母是什么以及儿童桌是什么。您是否尝试删除子类中父级的链接?
public class dsRegistration
{
public int dsRegistrationID { get; set; }
public int dsExpressionOfInterestID { get; set; }
[Display(Name = "SLA")]
public bool SLAReceived { get; set; }
[DataType(DataType.Date)]
[Display(Name = "Date Received")]
public DateTime? SLAReceivedDate { get; set; }
}