-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate primary key constraint names after calling SetName on the entity type in a TPT scenario #22753
Comments
@roji Will this impact the PostgreSQL table naming plug-in? (i.e. Does it try to set the PK constraint name like this?) @sandord This is a limitation with the current design; we will need new API surface to be able to specify a different explicit constraint name for each table, since in the EF model all the types share a primary key. For now, the workaround is to rename the constraints in the migration. |
Duplicate of #19811 |
Not quite. This is about constraint names, not column names. I've updated the title and body to reflect this more explicitly. |
Thanks for looking into this. It still it feels a bit odd though that even doing The proposed workaround is a bit painful for us since we're using tooling to automatically recreate initial migrations during the development stage. |
#19811 also covers keys, indexes and foreign keys |
I'm on EF Core version
5.0.0-rc.2.20472.13
with SqlLite and Postgres and I noticed that I got clashing primary key constraint names in the generated migration.Here's a complete sample code that reproduces the problem:
Here's the generated migration code. It assigns the same
pk_players
constraint name to each of the table's primary keys.While SqlLite is fine with non-unique primary key constraint names, Postgres isn't and throws an SQL exception when applying the migration.
This problem is triggered by the following call, which in my opinion should be perfectly safe:
The text was updated successfully, but these errors were encountered: