dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.78k stars 3.19k forks source link

Pluralization Not Pluralizing Properly #23427

Closed deanhupp closed 2 years ago

deanhupp commented 3 years ago
  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.

ErikEJ commented 3 years ago

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

-NoPluralize
friedrichwilken commented 3 years ago

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.

ErikEJ commented 3 years ago

Yes, it is a breaking change, and documented here: https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/breaking-changes#pluralizer

deanhupp commented 3 years ago

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.

ajcvickers commented 3 years ago

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