当我尝试加载父实体的子实体时,它加载默认值.如果我尝试显式加载它会抛出异常 违反Multiplicity约束."CodeFirstNamespace.Association_Customer"关系的角色"Association_Customer_Target"具有多重性1或0..1.检索复杂图形的子实体时抛出此异常.
我有一个图表关联,它有一个子实体Customer,关系为1到0或1,并且具有独立关联.*主键*是共享的.我正在使用EF6.延迟加载已启用.
public class Association
{
public virtual long Id { get; set; }
public virtual string ExternalId { get; set; }
public virtual int OrganizationId { get; set; }
public virtual AssociationType AssociationType { get; set; }
public virtual Customer Customer {get; set;}
public Association()
{
Customer = new Customer();
}
}
Run Code Online (Sandbox Code Playgroud)
客户类.
public class Customer
{
public virtual long Id { get; set; } …Run Code Online (Sandbox Code Playgroud) entity-framework ef-code-first entity-framework-ctp5 entity-framework-6