dotnet-digital-ops/DigitalOps.Dal/MainDbContext.cs

30 lines
824 B
C#
Raw Permalink Normal View History

2025-01-02 15:10:52 -05:00
using DigitalOps.Dal.DbEntity;
using Microsoft.EntityFrameworkCore;
using Npgsql;
namespace DigitalOps.Dal;
public class MainDbContext(DbContextOptions options) : MainDbScaffoldedContext(options)
{
static MainDbContext() => NpgsqlConnection.GlobalTypeMapper
.MapEnum<OrganizationRole>("organization_role");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.HasPostgresEnum<OrganizationRole>("organization_role");
modelBuilder.Entity<OrganizationUser>(entity =>
{
entity.Property(organizationUser => organizationUser.Role)
.HasColumnName("role")
.HasColumnType("organization_role");
});
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
return;
}
}