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]
}
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With