Skip to content

On SQL Server, a default or comment change keeps the complex indexes on the column (#186) - #192

Merged
CaffeinatedCoder merged 1 commit into
release/5.xfrom
fix/186-sqlserver-alter-column
Oct 23, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/5.xfrom
fix/186-sqlserver-alter-column

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #186

Into release/5.x. Closes acts only on main, 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 AlterColumnOperation for 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 issues ALTER COLUMN only when alterStatementNeeded. A default is rendered as DROP CONSTRAINT plus ADD DEFAULT, and a comment as sp_addextendedproperty, neither of which touches an index. The rebuild runs offline on every edition but Enterprise.

Change

SqlServerComplexIndexMigrationsModelDiffer.RequiresIndexRecreation now applies IssuesAlterColumn, which follows EF Core 10's generator. It's true for the computed-column drop and re-add (ComputedColumnSql/IsStored), and for its alterStatementNeeded facets: CLR type, column type, Unicode, fixed length, length, precision, scale, row version, nullability, collation, and any annotation but SqlServer:Identity. A default or comment change alone keeps the index.

Also: a ### Changed answers row (root and SQL Server changelogs), a docs/upgrading.md entry, CLAUDE.md, and the three EF methods the entry cites added to DocumentationApiTests.ExternalApi.

Tests

🤖 Generated with Claude Code

…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>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.6.0 milestone Oct 23, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working severity/medium Inconsistency or failure in a narrow scenario package/sqlserver Affects EFCore.ComplexIndexes.SqlServer area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring labels Oct 23, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 7e1f62c into release/5.x Oct 23, 2026
13 of 16 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/186-sqlserver-alter-column branch October 23, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/indexes Complex-property, composite, unique and filtered indexes area/migrations The differs, snapshot format, EnsureCreated and design-time wiring bug Something isn't working package/sqlserver Affects EFCore.ComplexIndexes.SqlServer severity/medium Inconsistency or failure in a narrow scenario

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant