问题
I am using Entity Framework in my application,so I have mapped my property objects to database objects. The property objects have been defined using Column attribute.
Now,I want to order them,but I can't find the property in Column Attribute for Order.
I have included System.ComponentModel.DataAnnotations,but still not getting it
Thanks in advance
回答1:
just use :
using System.ComponentModel.DataAnnotations.Schema;
Code :
[Column("Name" , Order = 1)]
public int UserName { get; set; }
Notice : cloumn arder by default takes a big number so if you ordered only this column it will be first one in the table unless you ordered another column with a lower order number which is in this case : 0
来源:https://stackoverflow.com/questions/26303281/ordering-column-attributes-in-entity-framework