Open Closed

How can we create non-clustered indexes for column using abp suite #766


User avatar
0
safi created

Hi

I have created a entity from abp suite and now wants to create non clustered indexes for some column so can you please suggest me how I can do this or need to do modification in migration file.

Thanks,

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

4 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Fullstack Developer

    Hi,

    Open your <YourProjectName>DbContextModelCreatingExtensions.cs class and use HasIndex to configure your entity.

    Example:

    builder.Entity<MyTest>(b =>
    {
        b.ToTable(qaConsts.DbTablePrefix + "MyTests", qaConsts.DbSchema);
        b.ConfigureByConvention();
        b.Property(x => x.Name).HasColumnName(nameof(MyTest.Name));
    
        // add this
        // specify name as an index
        b.HasIndex(x => x.Name);
    });
    

    Use the add-migration <migration file name> command to add migration file and run the DbMigrator project apply migration.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    safi created

    Hi

    I added above lines in specified file but If I am trying to add migration getting dept.json file not exist error.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Can you share some screenshots?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    safi created

    It's done now...Thanks @liangshiwei

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.