重复“列”属性
我正在使用 Entity Framework 4.1 创建一个实体,并使用列为列提供不同的名称。我有一个复合键和外键,但我收到错误
public class Account
{
[Key]
[ForeignKey("Account"), Column(Order = 0)]
[Column("Creditor ID", Order = 0)] //PK FK
public int CreditorId { get; set; }
[Key]
[ForeignKey("Account"), Column(Order = 1)]
[Column("[Account No]", Order = 1)] //PK FK
public int AccountNo { get; set; }
}
两者都是主键和外键
我收到以下错误:
重复的“列”属性
I am creating an entity using Entity Framework 4.1 and I am using column to give different names to columns. I have a composite key as well as foreign key but I am getting error
public class Account
{
[Key]
[ForeignKey("Account"), Column(Order = 0)]
[Column("Creditor ID", Order = 0)] //PK FK
public int CreditorId { get; set; }
[Key]
[ForeignKey("Account"), Column(Order = 1)]
[Column("[Account No]", Order = 1)] //PK FK
public int AccountNo { get; set; }
}
Both are primary key as well as foreign keys
I get following error:
Duplicate 'Column' attribute
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你确实这么做了!每个属性都定义了两个 ColumnArtribute 实例。它们位于不同的行并且位于不同的方括号中这一事实是无关紧要的。
在这两种情况下,第一行的内容看起来都是多余的。
Well, you do! each property has two ColumnArtribute instances defined. The fact that they are on different lines and in different sets of square brackets is irrelevant.
It looks like in both cases the one on the first line is redundant.