Efcore: Scaffold-DbContext singularizes results

Created on 17 Aug 2020  路  5Comments  路  Source: dotnet/efcore

I just tried to re-scaffold my tables with EF Core preview 7 and got some unexpected results. I think it all has to do with the new "EF core singularizes"-feature.

  1. A table named "Testergebnis" (test result - already singular) was renamed to "Testergebni" which is gramatically wrong (this can be mitigated by using -useDatabaseNames though)

  2. Some navigation properties received updates in names too:
    My Testbereich-table is linked via an n:m relational-table to a Protokoll-table. The n:m-relation tablename ProtokollTestbereich is now transformed into a ProtokollTestbereiches property which was previously transformed correclty into a navigation property with name ProtokollTestbereich (which is singular but one could get used to easily that might be a collection if one uses Intellisense /knows the datamodel).
    The new name is gramatically wrong ("ProtokollTestbereiche" would be correct). When trying to manually revert some changes I noticed that due to the intensivied(?) use of nameof() in annotations it would be a lot of more work to change those names back to the one previously used.

Are there any plans to preserve the old naming schema?

Further technical details

EF Core version: EF Core 5 Preview 7
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1.7
Operating system: Win 10 1909
IDE: Visual Studio 2019 16.7.1

closed-question customer-reported

All 5 comments

Pluralization enabled by default is hitting you.
You can use the No pluralize option:

--no-pluralize

Thanks. Eric! I could have tried to find it with Autocompletion, my bad.

I had lookedhere https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell and on the blog post introducing that preview-feature.

I just noticed that data annotations for max string length (e. g. [StringLength(50)]) have been removed,too? Is this by intention. At least autocomplete did not show anything that hints for another option ;)

I am not aware of any changes relating to DatAnnotations - are you using the " use DatAnnotations" option?

Could be related to #21897

@janschreier Discussed with the team and #21897 should have fixed the MaxLength bug. This fix is available now in the latest daily builds.

Was this page helpful?
0 / 5 - 0 ratings