相关疑难解决方法(0)

发出加载父实体的子实体的问题.单向映射和1到0..1与共享主键的关系?

当我尝试加载父实体的子实体时,它加载默认值.如果我尝试显式加载它会抛出异常 违反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

2
推荐指数
1
解决办法
2368
查看次数