简体   繁体   中英

Ordering Column Attributes in Entity Framework

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM