Tong
Tong

Reputation: 755

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; }
}

Upvotes: 4

Views: 1808

Answers (1)

howardlo
howardlo

Reputation: 1459

Have you looked at this plugin?

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

Upvotes: 2

Related Questions