我有以下类/实体:
public class Product : ISaleable
{
public void ProcessSale()
{
return;
}
[NotMapped]
private int id { get; set; }
[NotMapped]
private string productName { get; set; }
[NotMapped]
private decimal price { get; set; }
[NotMapped]
private TaxClass taxClass { get; set; }
[NotMapped]
private int quantity { get; set; }
[NotMapped]
private Member memberAssociation { get; set; }
public TaxClass TaxClass
{
get
{
return this.taxClass;
}
set
{
this.taxClass = value;
}
}
public int Quantity
{
get
{
return this.quantity;
}
set
{
this.quantity = value;
}
}
public string ProductName
{
get
{
return this.productName;
}
set
{
this.productName = value;
}
}
public decimal Price
{
get
{
return this.price;
}
set
{
this.price = value;
}
}
public Member MemberAssociation
{
get
{
return this.memberAssociation;
}
set
{
this.memberAssociation = value;
}
}
[Key]
public int ID
{
get
{
return this.id;
}
set
{
this.id = value;
}
}
}
如您所见,此类继承自ISaleable,并具有TaxClass类型的两个元素。现在,当项目运行时,EF尝试为该实体创建表时,我得到以下异常:
每个表中的列名必须是唯一的。列名称' TaxClass_ID' 在表格'产品'被指定不止一次。
我不确定为什么会发生这种情况,感谢任何帮助。
答案 0 :(得分:2)
尝试将public TaxClass TaxClass
重命名为public TaxClass MyTaxClass
。