Repository navigation
Description
2026-11-12, merged (#57, closed #48): the choice #48 left open is taken on the registry side. AddSchemaContributor<T>() and SchemaContributorRegistry both refuse a contributor that does not derive from SchemaContributor<,>; a base class of a package's own in between is taken. The base class refuses a null from Resolve and Claims as it does for Plan and ImpactOf. ISchemaContributor stays public; whether it should is a question for the freeze at rc.1. The planner (#24) therefore does not need checks of its own around a contributor's answers.
From #45, 2026-11-11: the contract's types exist. ISchemaContributor, SchemaContributor<TDeclaration, TDescriptor>, ISchemaDescriptor (Scope, Name, Dependencies, WithName), the closed SchemaChange, Impact, BaseChange, Dependency, NameClaim and SchemaPlacement, ValueList<T>, Operational<T> and AddSchemaContributor<T>() are in the kernel, public and experimental (SK9001). Plan and ImpactOf are abstract on the base class. SchemaChange.InPlace carries no statements: Plan writes them into the SchemaSql it is handed, and the base class refuses an answer that disagrees with what was written. SchemaResolver exists as what Resolve is handed and cannot be derived outside the kernel. The probes E10.render-a-declaration, X1, X2, X4, M1 to M3, P8 and the six P9 probes hold against the shipping assembly; X3 (a declaration in another provider's list) waits for the provider packages (#25, #29). Still open here: a contributor that implements ISchemaContributor itself passes the base class's refusals by, to decide before the freeze (#48); nothing calls a contributor yet (#43, #24), the built-in features as contributors (#25, #27, #29), the rule that a migration renders the same SQL whichever version applies it, and the page on writing a contributor.
From #42, 2026-11-11: the first part of the contract exists. The SQL vocabulary (Identifier, TableRef, QualifiedName, SqlName, SqlOperator, SqlFragment, SchemaSql, ISchemaDialect, SchemaDialect) and SchemaScope are public in the kernel, each marked [Experimental("SK9001")]; PublicSurfaceTests holds every public type outside the registration to that mark. What this issue adds goes under the same mark: ISchemaContributor, the typed base class, ISchemaDescriptor with Scope, Name and Dependencies, SchemaChange, Impact, NameClaim. The probe E4.render-a-declaration (a contributor's Create takes the descriptor, not the declaration) moves here from #23, since it needs the base class; the X probes follow it.
Decided 2026-11-11 (plan, section 3.10). The contract is ISchemaContributor with Resolve, Create, Drop, and two mandatory answers that replace the draft's optional hooks: Plan(from, to) returning a closed SchemaChange = None | InPlace | Rebuild, and ImpactOf(descriptor, change) returning Unaffected | Follows | Lost | Blocks. A descriptor has a Scope (table, schema or database), a QualifiedName and its Dependencies. It is marked experimental through the previews and freezes at rc.1, after a contributor outside this repository has compiled against it.
Problem
EF Core resolves IMigrationsModelDiffer and IMigrationsSqlGenerator as single services. A package that needs either one replaces it (ReplaceService, as this package does today). When two packages do, one silently wins (the last ReplaceService call), and the other package's declarations vanish from migrations without an error.
So this package can't be one of several migration-aware packages. That is the reason for the new name (#1): SchemaKit is the one owner of both services in the CodoMetis family, and everything else that needs them plugs in. "Schema" is the boundary. Whatever needs the differ or the migrations SQL generator belongs here or plugs in. Types, operators and query translation stay out.
Change
ROADMAP.md D10 (section 5.3) planned contributors as several DI registrations through an options extension, as an internal seam. Make it the public contract from 11.0.0:
-
A contributor interface (diff a model pair into operations, render an operation per provider) and a registration that adds contributors without touching the two EF services.
-
The built-in features (complex and expression indexes, exclusion constraints, typed filters, …) are contributors themselves, so the package's own features prove the contract, not only a sample.
-
Dependency direction: an ecosystem package ships an optional satellite that references the SchemaKit kernel, the way
CodoMetis.ValueRanges.NodaTimereferences its core. SchemaKit references none of them. The first prospective consumer is the ltree support in the planned CodoMetis.Hierarchies package: trigger-maintained paths, path checks, and any index options Npgsql'sHasMethod/HasOperatorscan't express. Its type and query translation never need the contract. -
The contract is public API under the same compatibility promise as the declaration API. The wiring call is renamed along with it (
UseSchemaKit(),ROADMAP.md5.6). -
A migration renders the same SQL whichever package version applies it. A migration stores operations, not SQL. The generator renders them when the migration is applied or scripted, so an operation rendered by whatever contributor version is restored today means something different from what was scaffolded. That matters most for an operation that installs a body: a trigger function (the Hierarchies paths above), a check, a SQL function. The contract fixes the rule:
- every operation carries the contract version it was diffed under, and a contributor keeps a renderer for every version it has shipped, or
- the operation carries its rendered SQL from scaffolding time, frozen in the migration file.
Changing a body is a new version. The snapshot records the version, so upgrading the package produces a migration that moves the database to the new body, instead of an old migration quietly applying it. Objects whose meaning a running application depends on (a function a query calls) use versioned names, so instances on the old and the new version can run side by side during a rolling deployment.
Done when
- A contributor written in a test project outside the package adds an operation that
migrations add,GenerateCreateScriptand the pending-changes check all see, on PostgreSQL and on SQL Server. - A migration scaffolded with one version of a test contributor, applied and scripted with the next version (whose body changed), renders the first version's SQL. The upgrade itself shows up as a pending model change.
- The built-in features are contributors.
docs/has a page on writing a contributor.- It ships in 11.0.0, because the contract can't change in a minor afterwards.
Activity
CaffeinatedCoder commentedon Oct 26, 2026
Added a requirement: a migration renders the same SQL whichever package version applies it, through versioned rendering or SQL frozen at scaffolding time, plus the matching Done-when line. It came up while evaluating SQL functions that ValueRanges could install through a contributor (CaffeinatedCoder/CodoMetis.ValueRanges#479, option 2). It applies to every contributor that installs a body, Hierarchies' trigger functions first.
[-]SchemaKit: a public plugin contract, so packages contribute to the model differ and migrations SQL generator instead of replacing them[/-][+]SchemaKit: the contributor contract, so packages add schema objects instead of replacing EF services[/+]