Repository navigation
Description
Found by a pre-release sweep of main @ 934ec55; reproduced in a scratch test. Both checks involved are new in the unreleased 5.5.0 (#93 and its follow-ups).
Problem
On PostgreSQL, a declaration on a TPC type whose derived table has a long name cannot be named at all:
- Default name: refused by
ThrowIfIdentifierTooLong(CustomMigrationsModelDiffer.cs:1185): "'IX_special_bookings_for_corporate_customer_accounts_xyz_1234_Code' … is 65 bytes long … Give the declaration an explicit, shorter name". - Explicit name: refused by
TpcDeclaration.RepeatedName(ValidateUniqueIndexNames,:948;ValidateNamesAcrossKinds): "… each time under the same explicit name … Leave the name out".
Each message points to the other. Exclusion constraints behave the same (a 51-character derived table gives 'EX_…_RoomId_During', 67 bytes), and temporal constraints go through the same checks (traced). EF Core's own HasIndex on the same model scaffolds, truncating and uniquifying the name. The model scaffolded under 5.4.x, which created the index on the base table only, so the first migrations add after the upgrade fails with no model change. SQL Server is not affected, since index names are unique per table there.
Model: Booking is TPC on bookings with HasComplexIndex(x => x.Code, isUnique: true); SpecialBooking : Booking is on special_bookings_for_corporate_customer_accounts_xyz_1234 (57 characters).
Change
Pick one:
- Give the TPC copies names the way EF Core does: truncate and uniquify the default name per table.
- Let an explicit name stand for the base table only, with derived copies taking a derived name.
At minimum, the length error must not advise an explicit name for a TPC declaration with derived tables. Whichever is chosen, the default-name rule is an answer the snapshot fixes, so a change after the tag needs the rendering-version gate. Deciding before 5.5.0 ships avoids that.
Tests
NpgsqlDiff(null, model) succeeds for the default-name model, or for an explicit-name one, for a complex index and for an exclusion constraint. Both are refused on HEAD.
Activity
CaffeinatedCoder commentedon Oct 20, 2026
Decision (2026-10-20): shorten TPC copies only. A TPC copy's default name over the provider's identifier limit is shortened the way EF Core does (
Uniquifier-style~, then~1,~2, … against the names already in scope), and that name appears in the scaffolded migration. The 5.2.0 refusal stays for every other default name, since an explicit name fixes those. The length error no longer advises an explicit name for a declaration on a TPC type with derived tables. TPC copies are new in the unreleased 5.5.0, so this changes no shipped answer and needs no rendering-version gate, provided it lands before the tag. A{table}placeholder in explicit names was considered and left for 6.0.