abp icon indicating copy to clipboard operation
abp copied to clipboard

sort the column in the table

Open md-yilmaz opened this issue 4 years ago • 3 comments

Hi I have Code, Field and Status Fields in almost all of my tables. Therefore, instead of writing for each entity that I will create these 3 fields, I created a code as follows.

public class BaseEntity : FullAuditedAggregateRoot { [Column(Order = 1)] public string Kod { get; set; } [Column(Order = 2)] public string Ad { get; set; } [Column(Order = 3)] public bool Durum { get; set; } }

However, when the Database is Generated, the image is as follows.

Code Named Situation ID ExtraProperties ConcurrencyStamp CreationTime creatorId My lastmodificationti LastModifierId IsDeleted DeleterId DeletionTime

However, I want the Id column to be at the top

How can I do it the way I want.

md-yilmaz avatar Mar 23 '22 11:03 md-yilmaz

Have you tried starting with Order=2

public class BaseEntity : FullAuditedAggregateRoot { [Column(Order = 2)] public string Code { get; set; } [Column(Order = 3)] public string Named { get; set; } [Column(Order = 4)] public bool Situation { get; set; } }

Alternatively you could edit the migration code created after you have used the add-migration command

Don

DonVliet avatar Mar 23 '22 14:03 DonVliet

This issue does not appear to be related to ABP.

You can still use @DonVliet's answer or the fluent API.

 modelBuilder.Entity<Employee>(x =>
    {
        x.Property(b => b.Id)
            .HasColumnOrder(0);

        x.Property(b => b.FirstName)
            .HasColumnOrder(1);

        x.Property(b => b.LastName)
            .HasColumnOrder(2);
    });

Note: You can use stackoverflow for such questions specific to your application.

berkansasmaz avatar Mar 23 '22 14:03 berkansasmaz

Thank you.

md-yilmaz avatar Mar 23 '22 18:03 md-yilmaz