Repository navigation
Description
Result, 2026-11-11: passed on Npgsql, SQL Server and SQLite (EF Core 11.0.0-rc.3), in #38. 69 conditions; each mechanism was removed in turn and its conditions failed. Runtime paths only: design time is #17.
| Condition | Outcome |
|---|---|
UseSchemaKit() after the provider, and before it |
SchemaKit outermost, the provider's own differ and generator inside, the declared object in GenerateCreateScript() |
No UseSchemaKit() |
Refused at the declaration, in OnModelCreating |
| Resolving both services while the model is built | No cycle on any provider |
Another package's ReplaceService<TService, X>() before |
X is the inner; both packages' operations are in the script |
| The same, after | Refused when the context is constructed: EF keeps one entry per service, so the two cannot both hold it |
ReplaceService<TService, MigrationsModelDiffer, X>(), before and after |
X is the inner |
A differ registered in another extension's ApplyServices, by type or factory, in either order |
It is the inner |
AddDbContext, AddDbContextPool (instance reused), AddDbContextFactory |
As the plain case, on every scope and instance |
UseInternalServiceProvider with the kit's services added to the collection |
As the plain case |
| The same without them | Refused when the context is constructed |
UseSchemaKit() called before UseInternalServiceProvider() |
Refused by EF itself (ReplaceService beside a caller-owned provider) |
| A registration added to a caller-owned collection after the kit's | Refused when the model is built: only the resolve-time check sees it |
| A replacement keyed on the kit's own type | Refused when the model is built |
| A model-cache hit (second context, same options) | The check ran once; the decorators are there both times |
A model cache shared through UseMemoryCache between options with and without the kit |
Silent. The context without the kit gets the stamped model and its script lacks the object. A fourth residual, now in the plan |
It takes three parts, not the one the plan assumed: taking over the ReplaceService entry, a registration of SchemaKit's own in ApplyServices, and the resolve-time check. The "it fails when" below did not happen.
Kills the design if it fails. No public API is written before A and B pass (plan, section 6).
Question
Can UseSchemaKit() wrap IMigrationsModelDiffer and IMigrationsSqlGenerator as decorators, taking over the CoreOptionsExtension.ReplacedServices entry and keeping an earlier replacement as the inner service, and can a model-initialized convention resolve both services while the model is being built and throw unless the outermost instance is SchemaKit's?
Conditions
Npgsql, SQL Server and SQLite; AddDbContext, AddDbContextPool, AddDbContextFactory, UseInternalServiceProvider; a model-cache hit (second context of the same type); another package's ReplaceService before and after; a later extension that registers a differ directly.
It fails when
Resolving the differ during model building cycles, or the check is skipped on a cache hit. Then the check moves to first use of the differ and to Validate, and the stamp still stands.
Done when
A throwaway project under spikes/ shows each condition's outcome in a table in this issue. Read from source so far, not run: CommandBatchPreparerDependencies takes no IModel (EF Core v11.0.0).
Activity