Skip to content

Validation and diagnostics: name claims across kinds, every finding at once #44

Open
1 of 1 issue completed

Description

@CaffeinatedCoder

2026-11-12, the name claims are #96 (PR #97): NameClaims in the planner, ISchemaDialect.Claims for EF Core's own objects, SchemaDiagnostic.NameCollision (SK1001) and SchemaValidationException with every finding at once, target only. The seed #84 left open (the constraint's name carrying its table's schema) now fails a test. All at once is implemented and still to be confirmed. Open here: ids for the kernel's existing refusals, warnings through the diagnostics logger, DeclarationRef (the diagnostic holds text for now), SQL Server's scopes (with #29), identifier-limit and whole-table findings as diagnostics.


From #84, 2026-11-12: PgExclusionContributor gives its descriptor a name without a schema, since a constraint is named within its table. A seeded defect that qualifies the name with the table's schema passes every test today: it changes no statement and no match. It will change what the name claims say, so the test for it comes with this issue.


A gap in the backlog, found while writing the handoff of 2026-11-11: validation is described in the design (section 9.8) and assumed by #7, #24 and #25, and no issue owns it.

Problem

What the types cannot forbid has to be reported at migrations add, EnsureCreated() and the pending-changes check: a name used twice, an identifier over the limit, a rule of the whole table. 5.x grew these checks one kind at a time, and each compared a kind with itself, which is not how PostgreSQL scopes names: a same-named exclusion constraint replaced a temporal one without an error.

Change

Design, section 9.8:

  • NameClaim, a closed union of the namespaces a name occupies: Relation(schema, name), TableIndex(table, name), Constraint(table, name), Trigger(table, name). Each descriptor returns its claims; EF's own tables, indexes, keys and constraints are entered too; a collision is reported only when one party is SchemaKit's. Names compare by the provider's rule.
  • SchemaDiagnostic, a closed union with a stable id per finding (SK1001 name collision, …), each carrying the declaration it is about.
  • All at once: every finding of the target model in one SchemaValidationException. The draft's open question Q7 assumes yes; confirm with the maintainer.
  • Target only: a snapshot that already holds a collision stays diffable.
  • The exceptions the kernel throws today as InvalidOperationException with a text from SchemaKitStrings (the wiring guards, the dialect's checks) get ids of the same scheme.
  • Warnings go through IDiagnosticsLogger<DbLoggerCategory.Migrations> with event ids, so ConfigureWarnings can raise them.

Done when

  • A collision across two kinds (an index and an exclusion constraint of one name) and one with an EF-owned object are each reported with both parties named, on PostgreSQL and SQL Server scopes.
  • Two findings in one model arrive in one exception.
  • A collision that exists only in the snapshot does not stop a diff.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added this to the 11.0.0 milestone on Nov 11, 2026
  2. added
    enhancement
    package/core
    area/migrations
    on Nov 11, 2026
  3. CaffeinatedCoder commented on Nov 14, 2026

    @CaffeinatedCoder
    OwnerAuthor

    From the pre-preview sweep of main @ 948496a, 2026-11-14. #100 is the null schema against public, and #99 the name a rename frees too late, which the end-state check cannot see. Two more leads, read and not run:

    • Implicit sequences are not claimed. An identity column makes {table}_{column}_seq, a relation of the schema. A constraint of that name fails at apply (42P07).
    • A name EF Core shortens by characters can be shortened again by PostgreSQL by bytes. The claim compares EF Core's full name, so a collision with a SchemaKit name of 63 bytes or fewer after the server's cut is missed.

    Checked and sound: SK1001 cannot fire on a model without a SchemaKit declaration (nothing is checked when the target declares nothing, and the pairs start from SchemaKit's own claims); one constraint name on two tables, a check constraint against an exclusion constraint on different tables, one name in two schemas, and names that differ in case all agree with the server.

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/core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions