Column Attributes in Entity Structure

I use the Entity Framework in my application, so I have mapped property objects to database objects. Property objects were defined using the Column attribute.

Now, I want to order them, but I cannot find the property in the Attribute column for the order.

I have included System.ComponentModel.DataAnnotations but still not getting it

Thanks in advance

+8
c # entity-framework-5 entity-framework-4
source share
1 answer

just use:

using System.ComponentModel.DataAnnotations.Schema; 

The code:

  [Column("Name" , Order = 1)] public int UserName { get; set; } 

Note: cloumn arder accepts a large number by default, so if you ordered only this column, it will be the first in the table if you did not order another column with a lower serial number, which in this case: 0

+11
source share

All Articles