Skip to content

Never replace EF Core's model differ or migrations SQL generator: a convention test and an AGENTS.md rule #334

Closed

Description

@CaffeinatedCoder

Problem

EF Core resolves IMigrationsModelDiffer and IMigrationsSqlGenerator as single services. When two packages replace one of them, the last registration wins, and the other package's migration DDL disappears without an error.

From 11.0.0 on, CodoMetis.EFCore.SchemaKit is the one owner of both services in the CodoMetis family. It offers a contract to plug into (CaffeinatedCoder/CodoMetis.EFCore.SchemaKit#7) and fails at startup when something else has replaced them (CaffeinatedCoder/CodoMetis.EFCore.SchemaKit#8).

The EF packages here touch neither service today. Checked 2026-10-19: no ReplaceService and no registration of either service in src/. The custom store types (timerange, float8range, float4range) are created through Npgsql's HasPostgresRange, not through a differ of ours. Nothing keeps it that way.

Change

  • A convention test in test/CodoMetis.ValueRanges.Conventions.Tests/ that fails on any type in a shipping EF assembly implementing or deriving from either service, and on any ReplaceService or service registration of them in src/ (a source scan, as EngineDispatchConventionTests does). It discovers the projects, so a new EF satellite is covered with no edit.
  • A Critical Rules entry in AGENTS.md: a migration-aware feature goes into SchemaKit or plugs into its contract, never into a replacement of those two services here.
  • Seed the defect (a ReplaceService<IMigrationsSqlGenerator, …> in a scratch copy) and show the test fails.

Lines

Merges into main, then is cherry-picked (-x) to release/10.x, because the rule holds on both lines.

Activity

  1. added this to the 11.0.0 milestone on Oct 19, 2026
  2. added
    tests
    package/efcore
    package/efcore-nodatime
    on Oct 19, 2026
  3. CaffeinatedCoder commented on Oct 19, 2026

    @CaffeinatedCoder
    OwnerAuthor

    Open: #337 (main) and #339 (the -x pick onto release/10.x, to merge after #337). Each passes CI. #337 closes this issue when it merges. Seeded in a scratch copy: a ReplaceService<IMigrationsSqlGenerator, …> with a derived generator fails both tests; a ServiceDescriptor registration of the differ in the NodaTime satellite fails the source scan; and removing the registrations trips the floor.

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

    package/efcorepackage/efcore-nodatimetests

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions