我正在使用带有 DB 优先方法的 EF。我在更新 EDMX 文件时遇到问题。假设我有一个表 InvoiceT 和另一个表 LookupT。现在,在 InvoiceT 中,我有一列 InvoiceType 与 LookupT 具有 FK 关系。现在实体在 InvoiceT 类中创建了一个名为 LookupT 的导航属性。到目前为止,它很好。
现在我用 LookupT 添加了另一个名为 InvoiceStatus 和 FK 的列。现在实体创建另一个名为 LookupT1 的导航属性。但是这里的问题是第一个导航属性 LookupT 没有指向它的原始数据,即 InvoiceType。相反,它现在指向 InvoiceStatus 数据。任何人都可以向我解释为什么它会这样,我该怎么办?
public class InvoiceT
{
public int InvoiceId {get;set;}
public int InvoiceStatusLkpId {get;set;}
public int InvoiceTypeLkpId {get;set;}
public virtual LookupT LookupT {get;set;} // Previously pointing to Type. Now to Status.
public virtual LookupT LookupT1 {get;set;} // Pointing to Type
}
public class LookupT
{
public int LookupId {get;set;}
public string LookupValue {get;set}
public virtual ICollection<InvoiceT> InvoiceT {get;set;}
public virtual ICollection<InvoiceT> InvoiceT1 {get;set;}
}