Skip to content

Scope key name uniqueness to schemas - #4000

Merged
roji merged 1 commit into
mainfrom
roji-triage-issue-3704
Oct 17, 2026
Merged

roji merged 1 commit into
mainfrom
roji-triage-issue-3704

Conversation

@roji

@roji roji commented Oct 17, 2026

Copy link
Copy Markdown
Member

PostgreSQL allows the same primary key name in different schemas, but the provider currently uniquifies names globally, causing unnecessary primary key drop/recreation during migrations.

Override KeysUniqueAcrossSchemas while retaining key-name uniqueness across tables within each schema. Add regression coverage for identically named tables in different schemas.

Uses the EF Core 11 API added in dotnet/efcore#37861; this does not provide a 10.x backport.

Fixes #3704

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 772cff9a-c677-40a8-b85d-fad0c6c188ba
Copilot AI balanced review requested due to automatic review settings October 17, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused override addresses the reported issue with targeted regression coverage and no identified blockers; tests were not executed.

No open issues 🎉

What changed in this PR

Scopes PostgreSQL key-name uniqueness to schemas, preventing unnecessary primary key recreation during migrations.

Changes:

  • Allows identical key names across schemas while preserving uniqueness across tables within each schema.
  • Adds regression coverage for identically named tables in different schemas.
File Description
test/​EFCore.PG.Tests/​Metadata/​Conventions/​NpgsqlSharedTableConventionTest.cs Verifies primary key names remain unchanged across schemas.
src/​EFCore.PG/​Metadata/​Conventions/​NpgsqlSharedTableConvention.cs Overrides KeysUniqueAcrossSchemas to return false.

Review effort: Balanced

@roji
roji merged commit 5a47667 into main Oct 17, 2026
16 checks passed
@roji
roji deleted the roji-triage-issue-3704 branch October 17, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to .NET 10 - migrations drop and recreate primary keys for same name PKs on different schemas

2 participants