0
我在实体框架中使用第一种方法。我收到以下错误。EF:无效的列名'Party_ID'
无效的列名'Party_ID'。 exec sp_executesql N'INSERT [dbo]。[PartyCellPhone]([ID],[Party_ID],[CountryCode],[Number]) VALUES(@ 0,NULL,NULL,@ 1)',N'@ 0 int ,@ 1个为nvarchar(最大) ”,@ 0 = 13,@ 1 = N'1234546877'
的InnerException = { “无效的列名称Party_ID'。”}
public abstract class PartyContact:BaseModel
{
public PartyContact()
{
}
[Key]
public int ID { get; set; }
//public Enums.ContactType ContactType { get; set; }
//public Enums.ContactUsage ContactUsage { get; set; }
public abstract Enums.ContactMethod ContactMethod { get; }
public int ContactTypeID { get; set; }
public int ContactUsageID { get; set; }
public int ContactMethodID { get; set; }
public int PartyID { get; set; }
public abstract bool Validate();
[ForeignKey("PartyID")]
public virtual Party Party { get; set; }
}
public class CellPhone : PartyContact, ICellPhone
{
public string CountryCode { get; set; }
public string Number { get; set; }
public override Enums.ContactMethod ContactMethod
{
get
{
return Enums.ContactMethod.Cell;
}
}
/// <summary>
/// Initializes a new instance of the ContactNumber class with default values.
/// </summary>
public CellPhone()
{
}
}
当我调用save方法,它向我显示这个错误。我该如何解决这个问题?
这里没有EF专家,但是您是否确认名称是DB上的Party_ID?你的参考文献有PartyId –