Skip to content

d-m-wilson/EFCore.Pluralizer

 
 

Repository files navigation

Bricelam.EntityFrameworkCore.Pluralizer

This project is a working sample that adds design-time pluralization to Entity Framework Core.

Usage

To use the package, simply install it. The pluralizer will be used when reverse engineering a model from an existing database.

Console:

dotnet add package info.dmwilson.EntityFrameworkCore.Pluralizer
dotnet ef dbcontext scaffold "Data Source=chinook.db" Microsoft.EntityFrameworkCore.Sqlite

PMC:

Install-Package info.dmwilson.EntityFrameworkCore.Pluralizer
Scaffold-DbContext 'Data Source=chinook.db' Microsoft.EntityFrameworkCore.Sqlite

How it works

On install, the package adds an assembly-level attribute to the project:

[assembly: DesignTimeServicesReference(
    "Bricelam.EntityFrameworkCore.Design.EFCorePluralizerServices, Bricelam.EntityFrameworkCore.Pluralizer")]

This attribute points to a class that registers the IPluralizer service.

class EFCorePluralizerServices : IDesignTimeServices
{
    public void ConfigureDesignTimeServices(IServiceCollection services)
        => services.AddSingleton<IPluralizer, Pluralizer>();
}

At design time, EF Core will find the assembly-level attribute and call the ConfigureDesignTimeServies method to register additional services.

About

Adds design-time pluralization to EF Core

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 85.2%
  • PowerShell 14.7%
  • Batchfile 0.1%