How to disable agreements in Microsoft.EntityFrameworkCore?

I use SQLite with EFCore, but I have a problem ... how can I disable conventions like Pluralize? Is it possible?

My ModelBuilder has no property restrictions ...

protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder. [NOT HAS PROPERTY CONVENTION] } 
+8
source share
1 answer

You can disable the plural 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(); } 
0
source

Source: https://habr.com/ru/post/1266986/


All Articles