无法确定类型之间的关联的主要终点 [英] Unable to determine the principal end of an association between the types
本文介绍了无法确定类型之间的关联的主要终点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到这个错误:
无法确定为CustomerDetail的
类型之间的关联的主要结束,客户。
Unable to determine the principal end of an association between the types CustomerDetail and Customer.
下面是我的客户
和为CustomerDetail
模式
[Table("CUSTOMER")]
public class Customer
{
[Required]
[Column("CUSTOMER_ID")]
public int Id {get; set;}
[Column("FIRST_NAME")]
public string FirstName {get; set;}
// other fields
public virtual CustomerDetail customerDetail {get; set;}
}
[Table("CUSTOMER_DETAIL")]
public class CustomerDetail
{
[Required]
[Column("CUSTOMER_DETAIL_ID")]
public int Id {get; set;}
// other fields
public virtual Customer Customer {get; set;}
}
客户
到为CustomerDetail
有一个1:1的关系。
Customer
to CustomerDetail
has a 1:1 relation.
推荐答案
我认为你必须指定在一个 ForeignKey的
关系存在于实体映射到关键属性客户
属性。
I think that you have to specify a ForeignKey
relation on the Customer
property that maps to the key property exists on the entity.
[Table("CUSTOMER_DETAIL")]
public class CustomerDetail
{
[Required]
[Column("CUSTOMER_DETAIL_ID")]
public int Id {get; set;}
// other fields
[ForeignKey("Id")]
public virtual Customer Customer {get; set;}
}
的这个问题指的是不同的错误,但也有类似的目标,以什么你想实现的。
This question refers to a different error, but has a similar goal to what you are trying to achieve.
这篇关于无法确定类型之间的关联的主要终点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文