比如:
public class LineItem { [Key] public int OrderId { get; set;} [Key] public int LineNum { get; set;} public string ItemId { get; set;} public int Quantity { get; set;} public decimal UnitPrice { get; set; } }
编译时会出现如下错误:Unable to determine composite primary key ordering for type *****Use the ColumnAttribute or the HasKey method to specify an order for composite primary keys.
解决办法是给主键加上顺序:
分别加上:[Column(Order = 0)]
and [Column(Order = 1)]
学习交流群:364976091