【发布时间】:2012-01-14 18:46:31
【问题描述】:
我有以下类/实体:
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” 在表“产品”中多次指定。
我不确定为什么会发生这种情况,感谢任何帮助。
【问题讨论】:
标签: .net entity-framework c#-4.0