I have a table in SQL Server which includes custom nonclustered indexes for some columns. And I have also a project with below versions.
- .Net Framework 4.6.2
- Entity Framework 6.4.4
I added an entity data model to project based on my existing database (using a database-first approach).
Although a SELECT
query returns quickly in database, the same query gets a timeout error in the project. And I thought that EF couldn't add
column indexes to the project. I searched index names in the project,
but there isn't any code about indexes in the project.
So, how can I add indexes to my database-first model?
CodePudding user response:
So, how can I add indexes to my database-first model?
"database-first" means that you apply design changes to the database first, and then apply any changes to the EF model second.
So you just create the indexes in SQL Server using Visual Studio or SSMS, and since EF model doesn't need to change when you add an index, you're done.