Where is EnglishPluralizationService in EF Core 2.0?

c# entity-framework entity-framework-core pluralize

Question

EF Core 2.0 still has its conventions and it can change plural to singular and singular back to plural. Thus it definitely has the pluralization service built into it.

Yet I can't find this service to use it for other purposes.

In EF 6, I would write:

using System.Data.Entity.Infrastructure.Pluralization;

// Then somewhere in code
var englishPluralizationService = new EnglishPluralizationService();
var singularCat = englishPluralizationService.Singularize("Cats");
1
3
11/24/2017 10:01:25 AM

Accepted Answer

There is no built in pluralization in EF Core, but you can hook in for example the Inflector package: https://www.nuget.org/packages/Inflector/

I do that in "EF Core Power Tools" - see https://github.com/aspnet/EntityFrameworkCore/commit/dda3f43c046c2464f4813fdbb4261a6146aa4432 for more info

4
11/24/2017 10:16:07 AM

Popular Answer

EF Core 2.0 still has its conventions and it can change plural to singular and singular back to plural. Thus it definitely has the pluralization service built into it.

No, it can't do that and has no integrated pluralization service.

As explained in Table Mapping section of the documentation, it uses a simple convention:

By convention, each entity will be setup to map to a table with the same name as the DbSet<TEntity> property that exposes the entity on the derived context. If no DbSet<TEntity> is included for the given entity, the class name is used.

EF Core 2.0 introduced IPluralizer service that is used to singularize entity type names and pluralize DbSet names during scaffolding, but as stated in the link

this is just a hook where folks can easily plug in their own pluralizer

Shorty, there is no such service. For "other needs" you have to use your own or 3rd party pluralizer.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow