14

I'm using SQLite with EFCore, but I got a problem... how can I disable Conventions like Pluralize? Is it possible?

My ModelBuilder has not a property Conventions...

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
             modelBuilder. [NOT HAS PROPERTY CONVENTION]
        }
Rafael
  • 966
  • 12
  • 22
  • Have you checked this: https://stackoverflow.com/questions/46837617/where-are-entity-framework-core-conventions ? – H. Herzl Oct 07 '18 at 17:32

2 Answers2

0

You can disable pluralizing naming convention as shown below.

public static class ModelBuilderExtensions
{
    public static ModelBuilder RemovePluralizingTableNameConvention(this ModelBuilder modelBuilder)
    {
        foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes())
        {
            if (entityType.ClrType == null)
                continue;

            entityType.Relational().TableName = entityType.ClrType.Name;
        }

        return modelBuilder;
    }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.RemovePluralizingTableNameConvention();
}
Mustafa Gursel
  • 782
  • 1
  • 7
  • 16
0

No! It's not possible in ef core. as @Mustafa told, you can override convention by fluent API configuration.

Mujan
  • 316
  • 1
  • 13