Scaffolder throws error if junction table foreign key columns have identical names #26496
Labels
area-scaffolding
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Milestone
In the new EF Core 6 Scaffolder junction tables are generated as many-to-many relationships and not as separate entities.
The scaffolder seems to be using the column names in the junction table to generate names of the navigation properties.
This will cause issues if you have multiple junction tables using the same column name (this can be quite common if a table has multiple junction tables to it self)
Expected behaviour:
It would be preferable if the scaffolder didn't fail but had a fallback for duplicate names (eg.
Products
andProducts1
).This behavious is already used if scaffolded tables have identical names.
Stack trace:
Reproduction:
This works with any table that has 2 junction tables connected to it where the junction tables are using the same column names.
Repo with SQL script to create a database that generates an error.
https://github.com/aboondeviant/ef-core-junction-table-issue
Include provider and version information
EF Core version: 6.0.0-rtm.21519.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 6.0.0-rc2
The text was updated successfully, but these errors were encountered: