简体   繁体   中英

Is Entity Framework Core migration can affect SQL Server indexes?

I want to create indexes in my DB SQL Server directly via SSMS for optimization purpose. I'm using Entity Framework core in my .NET Core web API and using EF Core DB migration. Will EF Core migration will affect or delete the existing indexes?

That depends on how you run your migration. You have to add another migration which creates indexes and apply only that migration. Refer link here .

This is something relatively easy to do,

Running a simple Add-Migration MigrationNameHere from the NPM command line should create you a new migration.

From there its simply a case of population the Up() and Down() with the index creation and dropping via the migrationBuilder.CreateIndex() or the migrationBuilder.DropIndex() methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM