msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
119 stars 21 forks source link

Bad intersection table generation when M:M tables have the same primary key name #64

Closed Olivercomputing closed 11 months ago

Olivercomputing commented 1 year ago

I like to use "id" as the primary key for all tables. I found out that an incorrect intersection table is being automatically generated for an M:M relationship between two tables both having "id" as the PK. A one column - "id" - table is generated, evidently because the intersection table is simply copying the primary key names from both tables and treating them as the same. Giving different PK names causes the (apparently) correct insection table to be created. However, this feels like an ugly hack. Ideally the code generation should create new column names in the intersection table.

One convention that could work is to simply append the table name to the column names with a simple delimiter (e.g. id_TABLE1 and id_TABLE2) , ensuring no name conflict and making it easy to parse apart if needed.

I'm not sure if this is an EFDesigner issue or an EF Core issue.

msawczyn commented 1 year ago

This is a regression. It's been reverted to the old behavior, and a fix will go out in v 4.2.5.