Repository navigation
On SQL Server, a default or comment change keeps the complex indexes on the column (#186) - #192
Merged
Conversation
…exes on the column EF Core emits an AlterColumnOperation for any column facet that differs, and its SQL Server generator issues ALTER COLUMN only for some of them: a default is DROP CONSTRAINT plus ADD DEFAULT, a comment sp_addextendedproperty. The SQL Server differ took every AlterColumnOperation on a column an index reads as in the way (#84, #141), so a default or comment change rebuilt every complex index on the column, offline on every edition but Enterprise. RequiresIndexRecreation now asks what EF Core's generator asks (IssuesAlterColumn: its alterStatementNeeded plus the computed-column drop and re-add). A type, length, nullability, collation or computed change still rebuilds the index. Closes #186 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #186
Into
release/5.x.Closesacts only onmain, so #186 is closed by hand after the merge.Problem
On SQL Server, changing only a column's default value, default SQL or comment dropped and re-created every complex index that reads the column. EF Core emits an
AlterColumnOperationfor any facet that differs, and the SQL Server differ treated every one of them on an indexed column as in the way (#84, #141). EF Core's own SQL Server generator issuesALTER COLUMNonly whenalterStatementNeeded. A default is rendered asDROP CONSTRAINTplusADD DEFAULT, and a comment assp_addextendedproperty, neither of which touches an index. The rebuild runs offline on every edition but Enterprise.Change
SqlServerComplexIndexMigrationsModelDiffer.RequiresIndexRecreationnow appliesIssuesAlterColumn, which follows EF Core 10's generator. It's true for the computed-column drop and re-add (ComputedColumnSql/IsStored), and for itsalterStatementNeededfacets: CLR type, column type, Unicode, fixed length, length, precision, scale, row version, nullability, collation, and any annotation butSqlServer:Identity. A default or comment change alone keeps the index.Also: a
### Changed answersrow (root and SQL Server changelogs), adocs/upgrading.mdentry, CLAUDE.md, and the three EF methods the entry cites added toDocumentationApiTests.ExternalApi.Tests
SqlServerColumnFacetTests: a default-value, default-SQL or comment change produces no index operations. A length, type, nullability or computed-column change still rebuilds exactly the index on that column.SqlServerIntegrationTests.Default_and_comment_change_keeps_the_index(CI only): applies a default and comment change with the index in place, and the index is still there.AlterColumnUnderIndexTestsand the A column rename drops and re-creates every complex index and exclusion constraint on the column #182 rename tests still pass.🤖 Generated with Claude Code