2011-04-25 82 views
0

我有以下的模型類在我的應用程序:重複屬性的實體模型類屬性錯誤

public class Dispute 
{ 
    public long DisputeId { get; set; } 

    //[ForeignKey("Creditor")] FK; 
    [Column("Creditor Registry ID")] 
    public long CreditorRegistryId { get; set; } 

    //[ForeignKey("Registrant")] FK; 
    public long BorrowerId { get; set; } 

    [ForeignKey("Account")] 
    [Column("Creditor Registry ID", Order = 1)] // Fk 
    public int AccountCreditRegistryId { get; set; } 

    [ForeignKey("Account")] 
    [Column("Account No", Order = 2)] // Fk 
    public int AccountNo { get; set; } 

    public virtual Account Account { get; set; } 
    public virtual ICollection<DisputeTransaction> DisputeTransactions { get; set; } 
} 

和我收到以下錯誤,當我運行應用程序:

指定的架構是無效的。錯誤: (90,6):錯誤0019:類型中的每個屬性名稱必須是唯一的。屬性名稱'Creditor Registry ID'已被定義。

賬戶表具有用於爭議實體的組合密鑰。

請建議解決方案。

謝謝。

回答

1

您確定您可以添加同一列「債權人註冊表ID」兩次和不同類型?

[Column("Creditor Registry ID")] 
public long CreditorRegistryId { get; set; } 

[ForeignKey("Account")] 
[Column("Creditor Registry ID", Order = 1)] 
public int AccountCreditRegistryId { get; set; } 

應的第二屬性是:

[ForeignKey("Account")] 
[Column("Account Credit Registry Id")] 
public int AccountCreditRegistryId { get; set; } 
+0

貌似複製和粘貼的編程風格:) – 2011-04-25 13:15:39

+0

不,我不知道。 Whar是另一種選擇? – DotnetSparrow 2011-04-25 13:24:03

+0

不是:[ForeignKey(「Account」)] [Column(「Creditor Registry ID」,Order = 1)] // Fk public int AccountCreditRegistryId {get;組; } – DotnetSparrow 2011-04-25 13:33:09

相關問題