Ordering Column Attributes in Entity Framework

旧街凉风 提交于 2019-12-14 03:45:20

问题


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

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