Repository navigation
feat: the kernel host, UseSchemaKit() with the differ and generator decorators and the wiring guards - #40
Merged
Conversation
…ecorators and the wiring guards The first shipping code (#21). UseSchemaKit() is the whole registration: no .targets, no design-time services reference. - SchemaKitModelDiffer and SchemaKitSqlGenerator decorate whatever the context would have had, found by replaying the other extensions' ApplyServices. No EF-internal type is named under src/; EF1001 is an error there and InternalApiConventionTests holds that nothing switches it off. - Three parts keep SchemaKit outermost, as spike A measured: the ReplaceService entry taken over (an earlier replacement becomes the inner), a registration of its own, and the ownership checks (Validate at construction, a model-initialized convention at model build). - The convention stamps the model; SchemaKitModelStamp.Require is what a declaration API calls first. It also refuses an assembly that still carries the 5.x design-time services reference. - The host knows nothing of declarations: it splices what an internal ISchemaOperationPlanner returns around the inner differ's operations, and HasDifferences runs the same plan. Rewriters for 5.x operations run before the inner generator, which gets the whole list in one call. - Public surface: UseSchemaKit() (two overloads) and AddEntityFrameworkSchemaKit(). PublicSurfaceTests holds it to that. 111 tests on Npgsql, SQL Server and SQLite: the spike's conditions against the real host, operation order, EF Core's design-time composition in process, EnsureCreated() on SQLite judged by the catalog. Thirteen mutations of the host each failed their tests. Built locally on SDK 11.0.100-rc.1 in a scratch copy. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #21
Problem
SchemaKit had a design, a prototype and two passed spikes, and no shipping code. Everything else in
preview.1(declarations, the planner, exclusion constraints) needs a host that puts SchemaKit's operations into every path that turns a model into DDL, and that fails loudly when it is missing or displaced.Change
src/CodoMetis.EFCore.SchemaKit, the kernel's first content:UseSchemaKit()(two overloads) andAddEntityFrameworkSchemaKit()forUseInternalServiceProvider. That is the whole public surface.SchemaKitModelDifferandSchemaKitSqlGenerator, decorators around whatever the context would have had.InnerServicesfinds it by replaying the other extensions'ApplyServicesinto a scratch collection, so no EF-internal type is named.ReplaceServiceentry taken over (an earlier replacement becomes the inner), a registration of its own inApplyServices, and the ownership checks.SchemaKitWiringConvention, at model creation: resolves both services and throws unless the outermost is SchemaKit's, refuses an assembly that still carries the 5.x design-time services reference, and stamps the model (CodoMetis:SchemaKit).SchemaKitModelStamp.Requireis what a declaration API will call first.ISchemaOperationPlannerreturns before and after the inner differ's operations;HasDifferencesruns the same plan.IMigrationOperationRewriters (for operations 5.x scaffolded, Legacy replay: migrations scaffolded by 5.x apply to a fresh database #28) run before the inner generator, which gets the whole list in one call.Also: a solution file, a
Testlane behind theCIgate, Dependabot entries, and the repository's documents (CLAUDE.md gets a section on the host; the plan's 3.2 and 3.3 follow what was built).Decisions made here, for review
DesignTimeServicesReferenceAttribute, not for a loaded assembly as the plan said. The attribute is what would put the 5.x differ in front at design time; a loaded assembly would be a guess. The plan is updated.test/…/Harness/TestKit.csstands in for the planning layer until Change planning and impact: SchemaChange, BaseChange, ImpactOf, dependencies #24.CodoMetis:SchemaKit=1. It lands in model snapshots, so name and value are permanent from 11.0.0 (SchemaKit: snapshot format v2 and CodoMetis: annotation keys ship in 11.0.0; the 5.x format is read forever (D11) #9).CodoMetis.EFCore.SchemaKit, as 5.x keeps its own in its namespace, not inMicrosoft.EntityFrameworkCore.Tests
111 tests on Npgsql, SQL Server and SQLite; no database but SQLite.
WiringConditionTests: spike A's 21 conditions against the real host.OperationOrderTests: creates after and drops before the inner operations, the inner list untouched,HasDifferencesfor a change only SchemaKit can see (the inner differ reports none), no planner, the rewriter in place and in order.DesignTimeTests: EF Core's ownDesignTimeServicesBuilderover a context with nothing butUseSchemaKit(): the design-time differ is the context's, a scaffolded migration creates the index after its table and drops it before, the snapshot records declaration and stamp, and withoutUseSchemaKit()scaffolding fails at the declaration.SqliteEndToEndTests:EnsureCreated(), judged bysqlite_master.InternalApiConventionTests,PublicSurfaceTests,LegacyPackageGuardTests.Thirteen mutations of the host, each in a scratch copy, each failed its tests: no resolve-time check (C20, C21), no own registration (C07, C08, C21), no
ReplaceServicetake-over (C05, C09, C16, C19), stamp not required (C03 and the design-time refusal),Validatewithout the ownership check (C06), the earlier replacement ignored (C05, C19),HasDifferencesdelegated to the inner differ, the plan spliced in the wrong order, the generator skipping rewriters, a shipping file disablingEF1001, a public type leaked, the legacy guard matching a namespace, the stamp never written.Not covered here:
EnsureCreated()on PostgreSQL and SQL Server (their lanes are #5), and the packed package from a consumer outside the repository, which spike B holds with its own kit until #34 moves it onto this package.Built locally on SDK
11.0.100-rc.1in a scratch copy; this PR's lanes are the run on SDK11.0.100.🤖 Generated with Claude Code