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,
4 Answer(s)
-
0
Hi,
Open your
<YourProjectName>DbContextModelCreatingExtensions.cs
class and useHasIndex
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 theDbMigrator
project apply migration. -
0
Hi
I added above lines in specified file but If I am trying to add migration getting dept.json file not exist error.
-
0
Can you share some screenshots?
-
0
It's done now...Thanks @liangshiwei