Search code examples
asp.net-coreentity-framework-corescaffolding

How to pluralize collections when performing scaffold dbcontext?


I performed a scaffold dbcontext and everything is fine exception the collections aren't pluralized. Is there an argument I can add to the command to fix this?

This is the command I ran:

dotnet ef dbcontext scaffold "my connection string" 
Microsoft.EntityFrameworkCore.SqlServer -o Entities -c DbEntities

What I want:

public partial class Client
{
    public int Id { get; set; }
    public ICollection<Order> Orders { get; set; }
}

What I'm getting:

public partial class Client
{
    public int Id { get; set; }
    public ICollection<Order> Order { get; set; }
}

Solution

  • Have you looked at this plugin?

    https://www.bricelam.net/2018/03/02/efcore-pluralization.html