Multiple Primary Key with asp .net mvc 3

 ̄綄美尐妖づ 提交于 2019-11-30 05:35:14
verdesmarald

Assuming this is actually a composite key, since you can't have 2 primary keys... The error message tells you exactly what to do, namely add an order. You can do this by adding [Column(Order = 0)] and [Column(Order = 1)] to your key columns.

For your example:

public class LineItem
    {
        [Key][Column(Order = 0)]
        public int OrderId { get; set;}
        [Key][Column(Order = 1)]
        public int LineNum  { get; set;}
        public string ItemId { get; set;}
        public int Quantity { get; set;}
        public decimal UnitPrice { get; set; }

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!