Skip to content

Core: refuse a satellite's index options instead of dropping them - #107

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/92-core-refuses-satellite-options
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/92-core-refuses-satellite-options

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #92

Stacked on #105 (#90), which is stacked on #103 (#91). Merge in that order. The .NET workflow runs only on PRs into main/release/**, so this branch's CI is a workflow_dispatch run on the same commit; pr-hygiene runs once the PR is retargeted to main.

Problem

The core differ forwards no property-level provider option (IsForwardedIndexAnnotation is false for everything). When a SQL Server or PostgreSQL model is diffed by the core differ instead of the satellite's, every property-level option is dropped without a word. That happens with UseComplexIndexes() where UseSqlServerComplexIndexes() / UseNpgsqlComplexIndexes() belongs, or when the satellite's .targets is not imported:

CREATE INDEX [cx_prop] ON [things] ([code]);   -- declared clustered, FILLFACTOR 80, PAGE compression

EnsureCreated() applied it cleanly. Entity-level options reached the operation, but without the satellite's checks or resolution: an INCLUDE list kept Address.Code as a column name, and nothing checked the clustered slot.

Change

  • CustomMigrationsModelDiffer:
    • Holds each satellite's forwarded options (its whitelist, plus PostgreSQL's Npgsql:StorageParameter: prefix), the provider namespace its type mapping source lives in, and the registration that selects its differ.
    • ValidateNoSatelliteOptions(target) runs with the other target-only checks. A declaration carrying an option of the provider being diffed, which this differ does not forward, throws and names the registration to use, at runtime and for dotnet ef.
    • Scoped to the provider being diffed. A model shared with SQLite tests keeps its Npgsql: / SqlServer: options inert on SQLite, as EF does with other providers' annotations.
    • The satellites are unaffected. They forward their own options, and the other provider's prefix so that they can reject it.
    • Exact keys, never a prefix sweep, on the property level. Properties carry column facets under the same prefixes (SqlServer:ValueGenerationStrategy, Npgsql:Compression, …).
  • ComplexIndexDbContextOptionsExtensions: the remark on UseComplexIndexes() says it refuses those options.
  • BuilderApiParityTests.KeysSetBy exposes the existing builder-invocation loop for reuse.
  • Changed answer, so a row under ### Changed answers in the root and core changelogs, and an entry, "The core differ refuses SQL Server and PostgreSQL index options", in docs/upgrading.md:
    • An application on that misconfiguration now fails in EnsureCreated(), GenerateCreateScript() and Migrate(), whose pending-changes check runs the same differ. The fix is one line.
    • The root intro counts six such fixes now, and the upgrading intro says "most" re-create indexes (neither this one nor the SQLite one does).

Tests

CoreDifferSatelliteOptionTests, eleven tests:

  • Refusals: property-level SQL Server options, entity-level SqlServer:Include, Npgsql:IndexMethod, and Npgsql:StorageParameter:fillfactor. Each names the registration to use.
  • GenerateCreateScript() on a context with UseSqlServer(…).UseComplexIndexes() refuses.
  • Unaffected: the satellites keep their options, the three option-bearing models diff on SQLite without complaint, and a source snapshot carrying options is not checked.
  • Coverage: every key each satellite's builder can set is in the core's list.

Seeded, each failing as expected:

  • The ValidateNoSatelliteOptions call removed: the five refusal tests fail.
  • SqlServer:FillFactor removed from the core's list: the coverage test fails.
  • The check also run on the source: the target-only test fails.
  • The provider gating ignored: the shared-model SQLite row fails.

Full unit suite: 415 passed.

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred stacked Base is another open PR; merge in order, CI does not run until it targets main severity/low Cosmetic, message or documentation-level difference package/core Affects EFCore.ComplexIndexes area/indexes Complex-property, composite, unique and filtered indexes labels Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/90-sqlserver-clustered-and-key-names branch from a678e57 to 2a0060b Compare October 20, 2026 06:09
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/92-core-refuses-satellite-options branch from 98ea257 to 319ddbd Compare October 20, 2026 06:09
#92)

The core differ forwards no property-level provider option. When a SQL
Server or PostgreSQL model was diffed by it instead of the satellite's
differ (UseComplexIndexes() where UseSqlServerComplexIndexes() or
UseNpgsqlComplexIndexes() belongs, or no satellite .targets at design
time), INCLUDE, FILLFACTOR, ONLINE, SORT_IN_TEMPDB, DATA_COMPRESSION,
CLUSTERED or a GIN method vanished without a word, and EnsureCreated()
applied the rest cleanly. Entity-level options went through unchecked and
unresolved (INCLUDE kept property paths as column names).

The core differ now knows each satellite's forwarded options and the
registration that selects its differ. On the target model, a declaration
carrying an option of the provider being diffed that this differ does not
forward fails, naming that registration. Only the provider the differ serves
is checked, so a model shared with SQLite tests keeps its Npgsql options
inert, and the satellites, which forward their own options, are unaffected.

Verified by seeding: without the call, the five refusal tests fail; with
FillFactor missing from the core's list, the builder-coverage test fails;
checking the source too fails the target-only test; ignoring the provider
fails the shared-model SQLite test. BuilderApiParityTests exposes the
builder-invocation loop as KeysSetBy for reuse.

Changed answer: Changed answers row in the root and core changelogs, entry
in docs/upgrading.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/92-core-refuses-satellite-options branch from 319ddbd to 0c27caa Compare October 20, 2026 06:26
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from fix/90-sqlserver-clustered-and-key-names to main October 20, 2026 06:33
@CaffeinatedCoder
CaffeinatedCoder merged commit 204417b into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/92-core-refuses-satellite-options branch October 20, 2026 06:37
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 bug Something isn't working package/core Affects EFCore.ComplexIndexes severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred stacked Base is another open PR; merge in order, CI does not run until it targets main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The core differ silently drops SQL Server and Npgsql index options when it diffs a model a satellite should

1 participant