You can specify the column order in the attributes, for instance:
public class MyEntity
{
[Key, Column(Order=0)]
public int MyFirstKeyProperty { get; set; }
[Key, Column(Order=1)]
public int MySecondKeyProperty { get; set; }
[Key, Column(Order=2)]
public string MyThirdKeyProperty { get; set; }
// other properties
}
If you are using the Find
method of a DbSet
you must take this order for the key parameters into account.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…