Efcore: Pluralization Not Pluralizing Properly

Created on 21 Nov 2020  ·  5Comments  ·  Source: dotnet/efcore

  1. EF Core 5.0 when doing Scaffold-DbContext “SERVER=000.000.000.0000\SQL2016;DATABASE=fillerDb;USER ID=temp_user;PWD=Yourp@ssword;” Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force
    to add a table to my model causes pluralization of database objects by default. The main problem is that is pluralizes occurrences of specific phrases rather than words. It took a table called specimen and made it speciman and causing 108 compile errors. Pacmen gets changed to Pacman, etc... This is obviously wrong.

  2. I don't think pluralization should be turn on by default in an existing project. The renaming of database objects in the model is obviously going to reek havoc in an existing project with an existing model. This should not be turned on by default. Frankly, I don't know why you would ever turn this on when scaffolding a database model from a database. I think generally you would always want your model to mimic the database rather than rename things. For a new project it doesn't hurt anything though so I get it. For an existing project where code already references the model as it was created in the database, this defaulting to on is horrendously bad. If the EF Core doesn't have the ability to detect if a model already exists in the project then this should just never be turned on be default.

closed-question customer-reported

All 5 comments

You can just use the new option - https://docs.microsoft.com/en-us/ef/core/cli/powershell#scaffold-dbcontext

-NoPluralize

You can just use the new option - https://docs.microsoft.com/en-us/ef/core/cli/powershell#scaffold-dbcontext

-NoPluralize

That is true. But it is a little odd that pluralization used to be turned off by default for scaffolding in efcore 3.x. I was a little surprised when I used efcore 5 for the first time. But maybe there is a reason for that change.

It doesn't work right. Specimen shouldn't change to Speciman. I don't know why this is closed. The pluralization had bugs as documented in the original post.

@deanhupp This appears to be a bug in Humanizer. Please report it at: https://github.com/Humanizr/Humanizer

Was this page helpful?
0 / 5 - 0 ratings