You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use Scaffold-DbContext to generate entity classes and db context from a legacy SQLServer database.
Several of the tables in the database ends with a plural 's', including the table "CarDrivers" containing a many-to-many relationship between tables "Car" and "Driver".
The pluralizer removes this ending 's' from table names when creating entity classes, and that's fine.
But when generating the many-to-many relationship, this now causes an error.
In EF Core 6, .ToTable("CarDrivers") was added that made this work, but now in EF Core 7 this ToTable is removed causing SQLException Invalid object name 'CarDriver'
The many-to-many relation generated with EF Core 6:
Note the j.ToTable("CarDrivers"); is missing in the EF Core 7 code.
By adding -NoPluralize in the Scaffold-DbContext command line, the generated code is correct, as the joinEntityName is set to "CarDrivers" instead of "CarDriver", but then many of the class names and collection properties changes, causing lots of errors in the code base, so this is not a desirable workaround.
The text was updated successfully, but these errors were encountered:
We use Scaffold-DbContext to generate entity classes and db context from a legacy SQLServer database.
Several of the tables in the database ends with a plural 's', including the table "CarDrivers" containing a many-to-many relationship between tables "Car" and "Driver".
The pluralizer removes this ending 's' from table names when creating entity classes, and that's fine.
But when generating the many-to-many relationship, this now causes an error.
In EF Core 6, .ToTable("CarDrivers") was added that made this work, but now in EF Core 7 this ToTable is removed causing SQLException Invalid object name 'CarDriver'
The many-to-many relation generated with EF Core 6:
The many-to-many relation generated with EF Core 7:
Note the
j.ToTable("CarDrivers");
is missing in the EF Core 7 code.By adding -NoPluralize in the Scaffold-DbContext command line, the generated code is correct, as the joinEntityName is set to "CarDrivers" instead of "CarDriver", but then many of the class names and collection properties changes, causing lots of errors in the code base, so this is not a desirable workaround.
The text was updated successfully, but these errors were encountered: