Skip to content

The core differ refuses NULLS ordering and expression parts on SQL Server and PostgreSQL (#172) - #175

Merged
CaffeinatedCoder merged 3 commits into
mainfrom
fix/172-core-refuses-parts-on-sqlserver
Oct 20, 2026
Merged

CaffeinatedCoder merged 3 commits into
mainfrom
fix/172-core-refuses-parts-on-sqlserver

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #172

Problem

The packed core README says that on SQL Server, an index with DbOrder.NullsFirst/NullsLast "makes dotnet ef migrations add fail". That holds only when the SQL Server satellite's differ runs. #134's ValidateRenderableParts returned early on any provider that has a satellite. The core differ runs on SQL Server too: when a consumer installs only the core package, under UseComplexIndexes() in place of UseSqlServerComplexIndexes(), or without the satellite's .targets. There it scaffolded:

mb.Entity<NCommit>(b => b.HasComplexCompositeIndex(
    x => new { x.Created, Reviewed = DbOrder.NullsLast(x.ReviewedAt) }, indexName: "ix_commits_reviewed"));
CREATE INDEX [ix_commits_reviewed] ON [NCommit] ([Created], [ReviewedAt], [__requires_UseNpgsqlComplexIndexes__]);

That statement fails at apply, naming UseNpgsqlComplexIndexes() to a SQL Server consumer. Expression parts behave the same way, and so does the core differ on PostgreSQL.

Change

Labels follow the issue. Not breaking: the only setup that newly fails is the double registration above, which #150 already refuses for any satellite option or constraint.

Tests

  • CoreDifferIndexPartsTests, ten cases:
    • The core differ on SQL Server refuses NULLS ordering and expression parts with the SQL Server message, and the message never names UseNpgsqlComplexIndexes.
    • The core differ on PostgreSQL refuses both, naming UseNpgsqlComplexIndexes().
    • The SQL Server satellite still refuses both with its own message.
    • The PostgreSQL satellite still renders "ReviewedAt" NULLS LAST and (lower("Title")).
    • A snapshot that holds such an index stays diffable on SQL Server, and the index is dropped.
  • Reverted the fix (if (_satellite is not null)): the four refusal cases fail and the six controls pass.
  • SqlServerIntegrationTests.Core_registration_refuses_a_nulls_ordered_index: under UseComplexIndexes(), EnsureCreated() throws InvalidOperationException and cars doesn't exist, so the refusal came before any DDL. It runs only in CI. The proof run with the fix reverted, on the throwaway proof/169-172-revert branch, is reported below.
  • Unit suite: 641 passed (TestCategory!=Integration).

🤖 Generated with Claude Code

CaffeinatedCoder and others added 2 commits October 20, 2026 15:22
…QL Server and PostgreSQL (#172)

#134 refused these parts only on providers no satellite serves. Under
UseComplexIndexes(), or without a satellite's .targets, the core differ runs on
SQL Server and PostgreSQL too, and it scaffolded such an index with the
runtime-wiring sentinel: the migration failed at apply naming
UseNpgsqlComplexIndexes(), on SQL Server as well, while the packed core README
said migrations add fails.

ValidateRenderableParts now returns early only for a satellite's own differ.
On PostgreSQL the message names the satellite's registration; on SQL Server it
says neither differ renders the part, as the SQL Server satellite already
refuses it. The three MigrationModelDifferTests that drove the core differ on
PostgreSQL to exercise parts plumbing now go through the Npgsql differ, which
inherits it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working severity/low Cosmetic, message or documentation-level difference package/core Affects EFCore.ComplexIndexes 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 20, 2026
@CaffeinatedCoder

Copy link
Copy Markdown
Owner Author

Proof with the fix reverted (throwaway proof/169-172-revert, ValidateRenderableParts back to if (_satellite is not null); run 39429925065, branch now deleted):

  • Integration (SQL Server 2022): 1 of 18 failed: Core_registration_refuses_a_nulls_ordered_index failed with "EnsureCreated() reached the server: SqlException: Column name 'requires_UseNpgsqlComplexIndexes' does not exist in the target table or view." That is the issue's apply-time failure on a real SQL Server 2022.
  • Test (ubuntu-latest) and Newest EF Core patch: 4 of 641 failed, the four CoreDifferIndexPartsTests refusal cases and nothing else.
  • Integration (PostgreSQL 18) and Consumer smoke test: passed.

@CaffeinatedCoder
CaffeinatedCoder merged commit 250db63 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/172-core-refuses-parts-on-sqlserver branch October 20, 2026 13:44
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/core Affects EFCore.ComplexIndexes package/sqlserver Affects EFCore.ComplexIndexes.SqlServer severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core differ on SQL Server scaffolds a NULLS-ordered or expression index that fails at apply; the core README says migrations add fails

1 participant