-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add support for defining included column for indexes in SQL server #12266
Add support for defining included column for indexes in SQL server #12266
Conversation
I've used
|
Rebased onto latest dev. One thing I think is worth noting is that Other than that I have not found any further issues, so this should be ready for review. |
@@ -1896,7 +1896,7 @@ protected virtual bool HasDifferences([NotNull] IEnumerable<IAnnotation> source, | |||
|
|||
foreach (var annotation in source) | |||
{ | |||
var index = unmatched.FindIndex(a => a.Name == annotation.Name && Equals(a.Value, annotation.Value)); | |||
var index = unmatched.FindIndex(a => a.Name == annotation.Name && AnnotationValueEquals(a.Value, annotation.Value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just call StructuralComparisons.StructuralEqualityComparer.Equals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a rule to SqlServerModelValidator
that throws if any of the included properties are not present on the entity type or are already part of the index
This was addressed here f947625 Let me know if I should rebase/squash changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please rebase and squash.
This commit adds `ForSqlServerInclude` extension to `IndexBuilder` allowing defining columns to be included in a index on sql server. Generic version of `IndexBuilder` together with its extensions is introduced to support expression parameter. Breaking change is introduced in `SqlServer` adding a property to interface - `ISqlServerIndexAnnotations.IncludeProperties`. `MigrationsModelDiffer` now uses structural comparison for annotations to support arrays as annotation value. Fixes #4846
Rebased and squashed. |
@Kukkimonsuta Thanks for your contribution! |
This PR adds
ForSqlServerInclude
extension toIndexBuilder
allowing defining columns to be included in a index on sql server.To support expression parameter a generic version of
IndexBuilder
is introduced in main EF assembly, however to avoid breaking changes (as requested in #4846 (comment)) this type is available only with new extensionForSqlServerHasIndex
for the time being.There is a breaking change in
EFCore.SqlServer
adding a property to interface -ISqlServerIndexAnnotations.Include
, which might be ok since it's maybe not really meant to be implemented by others? @ajcvickersI'm still investigating possible problems with migrations, so this is not yet ready.
Fixes #4846