我有一个使用以下模型的意向书表格
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 上的一对一关系
我是否需要使用数据注释,如果需要,有人可以指出我正确的方向吗?