using System.Text.RegularExpressions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace Infrastructure.Data { public static class ModelBuilderExtensions { public static void RemovePluralizingTableNameConvention(this ModelBuilder modelBuilder) { foreach (IMutableEntityType entity in modelBuilder.Model.GetEntityTypes()) { var tableName = entity.DisplayName(); var match = Regex.Match(tableName, "<(.+)>"); if (match.Success) { tableName = match.Groups[1].Value; } entity.Relational().TableName = tableName.ToLower(); } } } }