efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Feature Request: Specifying Included Columns for an Index

Open eriksendc opened this issue 11 years ago • 28 comments

Hi there,

Thanks again for the help with specifying an index using code first.

One thing that's commonly necessary in real world situations is a 'covering index', where you have the main columns that the RDBMS uses to search (seek), but then additional data is included in the index to prevent the RDBMS from having to go to the heap table to do an extra lookup. In SQL Server this list of columns goes after the INCLUDE keyword:

CREATE INDEX IX_SomeObject_SomeDateTimeProperty ON dbo.SomeObject (SomeDateTimeProperty) INCLUDE (SomeStringProperty)

I'm sure you know all this. You guys are gurus! :) Anyways, I understand that to target different RDBMS's you don't want to throw every feature of the RDBMS into EF, but I think that the concept of covering indexes is fairly mature and supported by all major RDBMS's in use today.

Please accept this as a long-term suggestion for EF7.

Thanks and regards, -Brian Eriksen

PS - When someone gives this a read, if there's a good resource that calls out how you deal with DB objects that EF doesn't handle, it'd be great to be directed to that. I'm transitioning to code first from database first, and I'm also used to having a database project to manage all DDL. Thanks so much in advance!

eriksendc avatar Nov 13 '15 18:11 eriksendc

Why not use a SSDT project in Visual Studio to manage all your database objects?

ErikEJ avatar Nov 13 '15 18:11 ErikEJ

Another possible answer to this is to use the Sql() method in your migrations to create the objects EF doesn't know about.

divega avatar Nov 13 '15 18:11 divega

We discussed in triage and concluded that for the moment using Sql(...) to create the index is the right approach. If we see a significant number of folks wanting to be able to specify included columns in the model then we may reconsider adding it to the core model.

rowanmiller avatar Nov 17 '15 21:11 rowanmiller

Thanks for considering this and providing me with direction.

-Brian

On Nov 17, 2015, at 4:37 PM, Rowan Miller [email protected] wrote:

We discussed in triage and concluded that for the moment using Sql(...) to create the index is the right approach. If we see a significant number of folks wanting to be able to specify included columns in the model then we may reconsider adding it to the core model.

— Reply to this email directly or view it on GitHub.

eriksendc avatar Nov 18 '15 15:11 eriksendc

@rowanmiller I need it too. It can be written as an extension method to IndexBuilder.

gdoron avatar Mar 06 '16 06:03 gdoron

+1 being able to write this in the fluent API and have the migration builder automatically pick up when I change something would be a really useful time-saver.

lcalabrese avatar Apr 26 '16 02:04 lcalabrese

+1 i need that too,

done it with sql during migration before.

but the problem is on each major release i wipe migrations and recreate a new initial migration to clean things up. on doing so i ofcourse lost all the manual index optimization that was done with sql migration rather than attributes and generated migration

JanEggers avatar Jun 07 '16 07:06 JanEggers

+1 We are looking forward to have this feature as well

etrafiee avatar Oct 05 '16 06:10 etrafiee

+1 I need that too, I'll have to use the method Sql.

munozjoseluis avatar Oct 14 '16 23:10 munozjoseluis

+1

adyrotaru avatar Nov 20 '16 18:11 adyrotaru

+1

ghost avatar Feb 10 '17 13:02 ghost

+1

jpiquot avatar Mar 12 '17 13:03 jpiquot

+1

vinniep79 avatar Apr 07 '17 15:04 vinniep79

+1

narendrachava avatar Apr 14 '17 18:04 narendrachava

+1

wertzui avatar Apr 20 '17 10:04 wertzui

+1

SergeBerwert avatar May 01 '17 09:05 SergeBerwert

+1

eriksteinebach avatar May 01 '17 13:05 eriksteinebach

+1

DragosBobolea avatar May 10 '17 09:05 DragosBobolea

+1

svallis avatar May 16 '17 17:05 svallis

+1

DR9885 avatar May 24 '17 21:05 DR9885