How to scaffold DbContext with plural DbSet property names in Entity Framework Core?

Short Answer

1. Install Package

Install-Package Bricelam.EntityFrameworkCore.Pluralizer

2. Run Scaffold-DbContext Command

Scaffold-DbContext -Connection "Server=<server>;Database=<dbname>;user id=<userid>;password=<pwd>;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data/EFModels/


Long Answer:

As pointed out by @KalinKrastev in the comments of @natemcmaster's answer. Pluralization in EF Core is possible using a package called Bricelam.EntityFrameworkCore.Pluralizer that can be installed using

in the Package Manager Console (PMC) or

dotnet add package Bricelam.EntityFrameworkCore.Pluralizer

using Dotnet cli.

After installing the package just use the regular Scaffold-DbContext command.

Scaffold-DbContext -Connection "Server=<server>;Database=<dbname>;user id=<userid>;password=<pwd>;" -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Data/EFModels/ -Force

See More About Bricelam's Pluralizer


Pluralization is possible in EF Core 1.1. As Rowan Miller described in its blog, you need to install the Inflector and implement IDesignTimeServices to control pluralization when scaffolding. However, be aware of it:

We put these services into *.internal namespaces and reserve the right to break the APIs at any point.

So this is why a full code example is not copied to here. This answer is not accepted for the same reason - I prefer to wait until we get a stable API.

Another issue you should consider - this solution is provider-dependent. It works fine with SQL Server (I tested it). Another DBMS provider may not support this API yet. For example, latest Npgsql.EntityFrameworkCore.PostgreSQL 1.1.0 fails on scaffold when custom IDesignTimeServices is used.


Update for EntityFrameworkCore 5.0 : TableNames are now automatically pluralized upon scaffolding. (At least with -Provider Microsoft.EntityFrameworkCore.SqlServer)