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");
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 noDbSet<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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With