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

Can HasIndex only be used for creating one index? #575

Closed
henrikdahl8240 opened this issue Jul 9, 2018 · 2 comments
Closed

Can HasIndex only be used for creating one index? #575

henrikdahl8240 opened this issue Jul 9, 2018 · 2 comments
Assignees

Comments

@henrikdahl8240
Copy link

henrikdahl8240 commented Jul 9, 2018

Using the HasIndex introduced by version 6.2 I have defined two indexes like this:
this.HasIndex(t => t.Col1ID).HasName("IX_Col1ID"); this.HasIndex(t => new { t.Col2ID, t.Col3, t.Col1ID }).HasName("IX_Col3Properties").IsUnique();
Interestingly only the index IX_Col3Properties is being created, the index IX_Col1ID is not being created.

Before, I defined both indexes using attributes on the Col1ID, Col2ID and Col3 properties of the POCO class. In that case both indexes were being created.

If I swap the two definitions, both of the two definitions will now result in an index in the database.

Is the rules for this "shooting game" documented anywhere, i.e. in which mutual order must multiple HasIndex invocations be done?

It seems quite odd, that it may be necessary to study the concrete indexes made in order to see, if Entity Framework has actually made the indexes defined by HasIndex.

Is it really correct, that HasIndex does not work correct for this typical pattern of usage?

At this moment it reads at https://www.nuget.org/packages/EntityFramework/ that version 6.2.0 was last updated 8 months ago and has 3.106.887 downloads. It should be one of the most downloaded packages. If I am right in what I have observed, wouldn't it be quite reasonable if you corrected your mistake(s) and made a new version available?

@chrisblock
Copy link

I also think this would be resolved by #534.

@ajcvickers
Copy link
Member

Duplicate of #460

@ajcvickers ajcvickers marked this as a duplicate of #460 Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants