TrackableEntities / EntityFrameworkCore.Scaffolding.Handlebars

Scaffold EF Core models using Handlebars templates.
MIT License
210 stars 53 forks source link

Entity Name in Plural Form #8

Closed noufionline closed 6 years ago

noufionline commented 6 years ago

Hi Tony,

Greetings again.

Is there any way you can help us to create entities without pluralization? We prefer Customer instead of Customers.

tonysneed commented 6 years ago

So there are a few steps to follow to use pluralization in EF Core.

public class MyPluralizer : IPluralizer
{
    public string Pluralize(string name)
    {
        return Inflector.Inflector.Pluralize(name) ?? name;
    }

    public string Singularize(string name)
    {
        return Inflector.Inflector.Singularize(name) ?? name;
    }
}
services.AddSingleton<IPluralizer, MyPluralizer>();

See here for more info: https://docs.microsoft.com/en-us/ef/core/what-is-new/