我在下面给出了我的实体的描述。它将更容易理解
家长实体
[Key]
[Column(Order = 0)]
[Required]
public virtual string Invno { get; set; }
[Key]
[Column(Order =1)]
[Required]
public virtual string Customer { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Sslno { get; set; }
public virtual ICollection<ChildEntity> ChildEntity { get; set; }
儿童实体
[Key]
[Column(Order = 0)]
[Required]
public virtual string Itemcode { get; set; }
[Key]
[Column(Order = 1)]
[Required]
public virtual double Price { get; set; }
[Key]
[Column(Order = 2)]
[Required]
public virtual int Sslno { get; set; }
[ForeignKey("Sslno")]
public virtual ParentEntity ParentEntity { get; set; }
给我错误:
关系约束中的从属角色和主要角色中的属性数必须相同
注意:我不想让Invno和客户成为外键