Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support an [Index] attribute #4050

Closed
rowanmiller opened this issue Dec 11, 2015 · 13 comments · Fixed by #21012
Closed

Support an [Index] attribute #4050

rowanmiller opened this issue Dec 11, 2015 · 13 comments · Fixed by #21012
Assignees
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Milestone

Comments

@rowanmiller
Copy link
Contributor

We didn't bring this over from EF6.x because it had a lot of issues... but opening this issue to track the possibility of adding it in the future since a number of folks have asked for it (see discussion on #1698).

@jsakamoto
Copy link

We didn't bring this over from EF6.x because it had a lot of issues...

I'm not sure about what problems are there due to I had not learned more about it. Anyway, I could not forget Index attribute...

So that, I create my own Index attribute library, and published it.

https://www.nuget.org/packages/Toolbelt.EntityFrameworkCore.IndexAttribute

This library allows us to easy way to recognize models without round trip between DbContext class and Entity classes.

I hope, this library to be useful for some people who could not forget Index attribute, and I hope it does not bother the developer community.

@rockstardev
Copy link

LOL @ "because it had lot of issues". Thanks for providing solution @jsakamoto

Inception when I see #1698

@davidrevoledo
Copy link

@jsakamoto awesome !

@CZEMacLeod
Copy link

It would be really nice to move/add IndexAttribute to the System.ComponentModel.Annotations or Microsoft.EntityFrameworkCore.Abstractions package, and align the attribute for EFCore vNext and EF6.3 to allow the use of annotations on the model, without forcing an ORM provider.

This would allow for migrating our existing app piecemeal, and re-using the model both server side (ASP.NET MVC5/WebAPI2/EF6) and in our offline client side apps (Xamarin.Forms)

Right now we are using a home grown solution similar to @jsakamoto's Toolbelt.EntityFrameworkCore.IndexAttribute but with our own abstractions package, an EF6 Convention in another package, and an EFCore ModelBuilder 'convention' in a third.

@roji
Copy link
Member

roji commented Feb 1, 2019

@CZEMacLeod we definitely intend to have an attribute-based method to define indices in EF Core, but it's unlikely this would reuse the IndexAttribute found in System.ComponentModel.Annotations or be the same across EF6 and EF Core. Among other things, that attribute has the SQL Server-specific property IsClustered(), and we're looking at more usable ways to define composite indices. But no decisions have been made yet.

@ajcvickers
Copy link
Member

@CZEMacLeod Also, the design of the Index attribute in EF6 is not very good, but we're not going to change it for EF6, so Core will definitely have a new attribute.

@weitzhandler
Copy link
Contributor

Would be nice to have an IsUnique modifier too.

@ajcvickers ajcvickers added this to the Backlog milestone May 10, 2019
@tidusjar
Copy link

I know you guys are super busy and have a lot of work to do at the moment but can someone please expand why this was taken out of the 3.0 release? Any idea when it might be placed in a different release?

@ajcvickers
Copy link
Member

@tidusjar It was taken out because we don't have enough resources to complete it in time for 3.0. We will re-assess the backlog following the 3.0 release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

@ajcvickers ajcvickers modified the milestones: Backlog, 5.0.0 May 4, 2020
@ajcvickers ajcvickers assigned lajones and unassigned roji May 4, 2020
@lajones lajones added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label May 28, 2020
@smitpatel
Copy link
Member

@lajones - Can you put a small design of IndexAttribute which is implemented, how to use it and limitations on it here (and also edit the first post to add it at the top). If you are planning to add it to docs next, then the link to docs site page would also be fine. It would make it easier for people who ends up here searching for this issue to know what we implemented.

@lajones
Copy link
Contributor

lajones commented May 28, 2020

@lajones - Can you put a small design of IndexAttribute which is implemented, how to use it and limitations on it here (and also edit the first post to add it at the top). If you are planning to add it to docs next, then the link to docs site page would also be fine. It would make it easier for people who ends up here searching for this issue to know what we implemented.

See the docs issue I just added.

@Sergio1C
Copy link

Hi guys. It is still in progress, isn't it?

@roji
Copy link
Member

roji commented Dec 27, 2021

@Sergio1C as the milestone shows, this was done for EF Core 5.0.0. You can see the documentation for the [Index] attribute on this doc page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. punted-for-3.0 type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.