constellation-api/CH.Dal/CHDbContext.cs

38 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using Npgsql;
using CH.Dal.DbEntity;
using CH.Enum;
namespace CH.Dal;
public class CHDbContext(DbContextOptions options) : CHDbScaffoldedContext(options)
{
static CHDbContext() => NpgsqlConnection.GlobalTypeMapper
.MapEnum<Currency>("currency")
.MapEnum<EnergyRateExceptionThresholdResetType>("energy_rate_exception_threshold_reset_type");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.HasPostgresEnum<Currency>("currency");
modelBuilder.HasPostgresEnum<EnergyRateExceptionThresholdResetType>("energy_rate_exception_threshold_reset_type");
modelBuilder.Entity<EnergyRate>(entity =>
{
entity.Property(e => e.Currency)
.HasColumnName("currency")
.HasColumnType("currency");
});
modelBuilder.Entity<EnergyRateException>(entity =>
{
entity.Property(e => e.ResetType)
.HasColumnName("reset_type")
.HasColumnType("energy_rate_exception_threshold_reset_type");
});
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
return;
}
}