【发布时间】:2019-11-26 09:35:32
【问题描述】:
我有一个名为Customer 的表,它有两个属性ReferrerCode 和OwnReferrerCode。客户注册时,可以输入另一个客户的推荐人代码,系统将分配一个唯一的OwnReferrerCode。多个客户可以使用特定客户的推荐代码。
public class Customer
{
[PrimaryKey]
public long CustomerId {get;set;}
public string ReferrerCode {get;set;}
public string OwnReferrerCode {get;set;}
public Customer ReferrerCustomer { get; set; }
public ICollection<Customer> ReferredCustomers { get; set; }
}
在配置文件中:
this.HasOptional<Customer>(s => s.ReferrerCustomer).WithMany(g => g.ReferredCustomers)
.HasForeignKey(s => s.ReferrerRewardCode);
显然会返回这个错误
The types of all properties in the Dependent Role of a referential constraint must be the same as the corresponding property types in the Principal Role.
有没有办法在 EF6
【问题讨论】:
标签: entity-framework entity-framework-6 one-to-many