Я хотел бы настроить ASP.NET Core Identity Framework + EF Core в Postgres с именами таблиц Snake_case в нижнем регистре. В настоящее время мой IdentityDbContext выглядит так:
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace TestProj.Identity;
public class IdentityDbContext : IdentityDbContext
{
public IdentityDbContext(DbContextOptions options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.LogTo(Console.WriteLine, LogLevel.Information)
.UseSnakeCaseNamingConvention()
.EnableSensitiveDataLogging();
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// correctly set the entity name types for postgresql
foreach (var entity in builder.Model.GetEntityTypes())
{
var tableName = builder.Entity(entity.Name).Metadata.GetTableName();
if (!string.IsNullOrEmpty(tableName))
{
if (tableName.Contains('
Подробнее здесь: [url]https://stackoverflow.com/questions/79244530/asp-net-core-identity-framework-ef-core-postgres-snake-case-table-names[/url]
Я хотел бы настроить ASP.NET Core Identity Framework + EF Core в Postgres с именами таблиц Snake_case в нижнем регистре. В настоящее время мой IdentityDbContext выглядит так: [code]using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging;
namespace TestProj.Identity;
public class IdentityDbContext : IdentityDbContext { public IdentityDbContext(DbContextOptions options) : base(options) { }
// correctly set the entity name types for postgresql foreach (var entity in builder.Model.GetEntityTypes()) { var tableName = builder.Entity(entity.Name).Metadata.GetTableName();
if (!string.IsNullOrEmpty(tableName)) { if (tableName.Contains('