Skip to content

Provider effect adapters: what a MigrationOperation does is the provider package's to say, not the kernel's #116

Open

Description

@CaffeinatedCoder

2026-11-25, where it stands. The seam and Npgsql's rules are in PR #199 (#198), which also closes #105. Left here, for the gate of rc.1: SQL Server's and SQLite's rules leave the kernel when each has a dialect to move to (#29, the first SQLite object), and with them the convention test that nothing under the kernel's src names a provider. Not built, and deviations from the proposal below, on #198: the second provider's probe dialects do not override the seam, and there is no separate service for a third package's operation types.


Decided 2026-11-25 by the maintainer: the proposal below, as written. The seam on the dialect, Npgsql's rules in its package for preview.2, the refusal of a move that is not written (#105), and the convention test with #29. The report upstream is the maintainer's; the reproduction is to be written here.


Proposal, 2026-11-25, together with #117. A sentence that says "measured" names where; everything else is a recommendation.

Where it stands

The kernel holds copies of three providers' rules, each held against its provider's generator by a test:

Rule Whose In the kernel as
Which operations a table is rebuilt for SQLite's BaseChanges.RebuiltOnSqlite, and IsSqlite, which compares the provider's name
An alter of a column's computation is a drop and an add Npgsql's and SQL Server's, with Npgsql's tsvector annotations BaseChanges.DroppedAndAdded
Operation types that change nothing Npgsql's and SQL Server's, by name the harmless list
A move back to the default schema is not written Npgsql's (#105) nowhere

The last is measured again today on Npgsql.EntityFrameworkCore.PostgreSQL 11.0.0: its generator writes ALTER TABLE role_grants SET SCHEMA grants; for a move into a schema and no statement at all for the move back. #105 holds on the released provider.

Neither package ships a dialect for SQL Server or SQLite. On those the kernel's own dialect is what a contributor gets, and the kernel's copies are what keep an object from being lost there (#145, #193).

Proposed

1. The seam: the dialect says what an operation does. ISchemaDialect gets one member that turns a MigrationOperation into the BaseChanges it stands for, or says it does not know the operation. The kernel's SchemaDialect answers EF Core Relational's own operations as today. A provider's dialect overrides it for what its generator does otherwise. An operation type of another package is described by a service that package registers, asked first. An operation nobody describes stays refused when a model declares an object.

2. For preview.2, Npgsql's rules move to NpgsqlSchemaDialect: its operation types, the tsvector part of the drop-and-add rule, and the move back to the default schema, which it says is not written.

3. What the planner does with a move that is not written (#105): refuse it, when a model declares an object on that table. The object would be created or kept in the schema the table is not in, or the create fails with 42P01. A context that declares nothing is not touched: the kernel reads no operations there. The refusal names the table and says to write the move by hand, with migrationBuilder.Sql, until the provider writes it.

4. SQLite's and SQL Server's rules stay in the kernel until each has a dialect to move to, which is #29 for SQL Server and the first SQLite object for SQLite. Moved out now, a contributor on a provider without a package would lose what protects it: the rules would have to be refused instead, and the kernel's own tests on the three providers would need a dialect each. The convention test of this issue's "done when" therefore comes with #29, not with preview.2.

5. The second provider's probe dialects override the seam for one rule each, as the evidence that the contract can say it.

Questions for the maintainer

  1. Is the refusal of A table moved back to the default schema stays where it was on Npgsql, and a statement written after the move fails with 42P01 #105 accepted? It refuses a migration that today applies and leaves the table where it was, for a model that declares an object on the table.
  2. May the convention test, no provider named under the kernel's src, wait for SqlServerIndex: clustered and nonclustered, typed #29?
  3. The report upstream (npgsql/efcore.pg) for the move back is yours to file; I can write the reproduction.

Before the contract freezes at rc.1; the seam before preview.2. From the architecture debate of 2026-11-14; not decided. Takes over #24's open item, a way for another package to say what its own operation type does.

Problem

What a MigrationOperation does to the database is the provider's rule, and the kernel holds copies of three providers' rules: SchemaOperationPlanner.IsSqlite compares the provider's name; BaseChanges.RebuiltOnSqlite is SQLite's rebuild list; BaseChanges.DroppedAndAdded is Npgsql's and SQL Server's and reads Npgsql:TsVector*; the harmless operations name two providers' types as strings. A fourth provider has no way in, another package's operation type is refused outright, and Npgsql's move back to the default schema, which it does not write (#105), has nowhere to be said. A raw SqlOperation counts as harmless, which nothing can know.

Change, to decide

The provider's package says what each operation it knows does: the BaseChanges, a drop and add, a rebuild, a move that is not written. The kernel keeps EF Core Relational's own operations. Another package registers an adapter for its operation types. An operation nobody describes stays refused when a model declares an object, with an explicit opt-out per operation type instead of none.

Held as today: each adapter against its provider's generator by a test, so that a provider's patch that changes the SQL fails the build.

Done when

No file under src/CodoMetis.EFCore.SchemaKit names a provider, a provider's operation type or a provider's annotation, held by a convention test like InternalApiConventionTests.

Activity

  1. added this to the 11.0.0 milestone on Nov 14, 2026
  2. added
    enhancement
    package/core
    package/postgresql
    package/sqlserver
    area/migrations
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/migrationsenhancementpackage/corepackage/postgresqlpackage/sqlserver

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions