Prior to EF Core 5, I've been able to use this code (pasted below) successfully from this original Stack Overflow post Entity Framework Core RC2 table name pluralization
This allowed me to specify SQL tables which persist my entities to use singular names. This doesn't appear to work after upgrading beyond EF Core 3. Most of the posts in Stack Overflow around this topic are dated many years prior. There is one post in the article linked above dated 1/29/2021 which makes mention of the "-NoPluralize" switch for Scaffold-DbContext, except I'm not scaffolding from an existing DB, I'm using the code-first methodology. This is also mentioned in Microsoft's https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-5.0/breaking-changes#pluralizer
I've also tried upgrading to EF Core 6.0.3 to see if this may have been addressed by chance in this release. Unfortunately no luck.
Stepping across the code for entity.SetTableName, both entity.DisplayName() and entity.ShortName() methods return the proper singular name strings, so I know SetTableName() is receiving the proper string.
Investigating the SetTableName method in the RelationalEntityTypeExtension class in the EF Core source out on GitHub doesn't reveal anything interesting or abnormal, that is if I'm looking at the correct class.
There's bound to be a solution for this, I couldn't possibly be the only one :-) Any suggested articles or techniques to try? The only thing left I can think of to try is to get breakpoints on some of the EF sources with some debug symbols and see what's going on beyond just my code. Any input or guidance would be tremendously helpful!
In my context class, pluralizing invoked by:
protected override void OnModelCreating(ModelBuilder modelBuilder){
modelBuilder.RemovePluralizingTableNameConvention();
}
In pluralizing method implemented in an extension class:
public static class ModelBuilderExtensions{
public static void RemovePluralizingTableNameConvention(this ModelBuilder modelBuilder){
foreach (var entity in modelBuilder.Model.GetEntityTypes()){
entity.SetTableName(entity.DisplayName());
}
}
}