You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify how EF uses indexes (i.e. currently only for update ordering) #1677
I understand that when using migrations, indexes defined in OnModelCreating will be created in the database.
I have an existing database, with indexes already set up, and was wondering if there is a benefit to defining these indexes in my DbContext? Does EFCore use these index definitions to influence how it builds queries, or does defining an existing index have no effect?
Thanks
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: f85ea32c-8d23-d61d-6036-cd772e3e95d9
Version Independent ID: 25dd8ac4-2521-5200-0ddf-63ac8c83787a
changed the title [-]Does defining an index using the fluent API have any effect when the index already exists on the database, and migrations are not being used?[/-][+]Clarify how EF uses indexes (i.e. currently only for update ordering)[/+]on Sep 2, 2019
Activity
smcga commentedon Aug 27, 2019
I found an answer for this on SO - https://stackoverflow.com/questions/54299018/what-is-the-benefit-of-adding-hasindex-in-your-mappings-on-a-dbfirst-scenari
tl;dr - If you are not updating the DB with migrations, this does nothing.
[-]Does defining an index using the fluent API have any effect when the index already exists on the database, and migrations are not being used?[/-][+]Clarify how EF uses indexes (i.e. currently only for update ordering)[/+]offirpeer commentedon Jul 14, 2020
If I created an index in my DB, how can I tell EF to use it when fetching the data?
https://stackoverflow.com/questions/62881671/ef-core-not-fetching-data-from-table-based-on-its-clustered-index