Skip to content

test: spike A, decorate the differ and the generator and check who owns them - #38

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
spike/16-decorator-ownership
Nov 11, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
spike/16-decorator-ownership

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #16

Problem

The core plan rests on SchemaKit decorating IMigrationsModelDiffer and IMigrationsSqlGenerator instead of deriving from EF's classes, and on a check, made while the model is being built, that the outermost instance of both is SchemaKit's. Both were read from EF Core's source and never run. Spike A is one of the two spikes that must pass before any public API is written.

Change

  • spikes/A.DecoratorOwnership (throwaway): the host in miniature (SpikeKit/), a stranger's package that replaces the differ the way packages do today (OtherPackage/), and 21 conditions over Npgsql, SQL Server and SQLite. No database is contacted. EF1001 is an error in the project, and only the stranger's code disables it.
  • design/schemakit-core-plan.md, section 3.2: the registration takes three parts, not one; a table of what another package's registration becomes before and after UseSchemaKit(); the UseInternalServiceProvider order; a fourth residual. Section 6 marks spike A as passed.
  • .github/workflows/dotnet.yml: a Spikes lane that runs every spikes/*/*.csproj, in the CI gate's needs.

What it answers

Question of #16 Answer
Decorate both services with public API only Yes. The inner service is found by replaying the other extensions' ApplyServices into a scratch collection; no EF-internal type is named
Keep an earlier replacement as the inner Yes, for ReplaceService, a type-specific ReplaceService, and a registration in another extension's ApplyServices, by type or factory
Resolve both services while the model is built No cycle on any of the three providers
A model-cache hit The check runs once per model build; the decorators are resolved per context and are there on every instance
A later service-only ReplaceService Cannot be composed with (EF keeps one entry per service). Refused when the context is constructed, naming the order to use
Pooled contexts, AddDbContextFactory, UseInternalServiceProvider All as the plain case; the caller-owned provider needs AddEntityFrameworkSchemaKit() on its collection and UseSchemaKit() after UseInternalServiceProvider()

Found beyond the question: a model cache shared through UseMemoryCache between options with and without the kit hands the stamped model to the context without it, and its create script silently lacks the declaration (C18). It joins the residuals the catalog verifier answers.

Tests

  • 69 of 69 conditions pass; the 72 probe tests still pass.
  • Each mechanism was removed in a scratch copy and its conditions failed: the resolve-time check (C20, C21), SchemaKit's own registration (C07, C08, C21), the ReplaceService take-over (C05, C09, C16, C19), the stamp (C03), Validate's ownership check (C06), the earlier replacement as inner (C05, C19).
  • Run locally on SDK 11.0.100-rc.1 in a scratch copy, since the released SDK is not installed on the machine that wrote it. This PR's Spikes lane is the run on SDK 11.0.100.
  • Not covered: design time, compiled models, bundles (spike B, Spike B: design time without .targets, from a packed consumer #17), and a live database.

🤖 Generated with Claude Code

…ns them

Answers #16 on Npgsql, SQL Server and SQLite with EF Core 11.0.0-rc.3: SchemaKit can
wrap IMigrationsModelDiffer and IMigrationsSqlGenerator through public API only, keep
another package's replacement as its inner service, and resolve both services while
the model is being built without a cycle.

- spikes/A.DecoratorOwnership: the host in miniature (SpikeKit/), a stranger's package
  (OtherPackage/), and 21 conditions over three providers (69 tests). EF1001 is an
  error in the project; only the stranger's code disables it.
- It takes three parts, each shown to fail its conditions when removed: taking over
  the ReplaceService entry, a registration of SchemaKit's own, and the resolve-time
  check. The plan's section 3.2 now says so, with what another package's registration
  becomes in each order.
- One more residual, measured: a model cache shared between options with and without
  the kit hands the stamped model to the context without it, silently (C18).
- dotnet.yml gets a Spikes lane behind the CI gate, so the answer is measured on the
  SDK global.json pins. Locally it ran on SDK 11.0.100-rc.1 in a scratch copy.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 11, 2026
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (harnesses, parity suites); no library code package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring labels Nov 11, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 11887a4 into main Nov 11, 2026
5 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the spike/16-decorator-ownership branch November 11, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/migrations The differ and generator decorators, snapshot format, EnsureCreated and the UseSchemaKit wiring package/core Affects CodoMetis.EFCore.SchemaKit (the kernel) tests Adds or changes tests only (harnesses, parity suites); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spike A: decorate the differ and the generator, with a resolve-time ownership check

1 participant