Possible to set column ordering in Entity Framework

前端 未结 2 632
小蘑菇
小蘑菇 2021-02-04 13:30

Is there any possible configuration to set database column ordering in entity framework code first approach..?

All of my entity set should have some common fields for ke

2条回答
  •  臣服心动
    2021-02-04 14:03

    Just use:

    using System.ComponentModel.DataAnnotations.Schema;
    

    Code:

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

    Notice: column order 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

提交回复
热议问题