IW4M-Admin/Data/MigrationContext/PostgresqlDatabaseContext.cs

36 lines
1.1 KiB
C#
Raw Normal View History

using System;
using Data.Context;
using Data.Extensions;
using Microsoft.EntityFrameworkCore;
namespace Data.MigrationContext
{
public class PostgresqlDatabaseContext : DatabaseContext
{
public PostgresqlDatabaseContext()
{
if (!MigrationExtensions.IsMigration)
{
throw new InvalidOperationException();
}
}
public PostgresqlDatabaseContext(DbContextOptions options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (MigrationExtensions.IsMigration)
{
2022-02-22 18:09:50 -05:00
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
optionsBuilder.UseNpgsql(
"Host=127.0.0.1;Database=IW4MAdmin_Migration;Username=postgres;Password=password;",
2022-01-28 15:33:08 -05:00
options => options.SetPostgresVersion(new Version("12.9")))
.EnableDetailedErrors(true)
.EnableSensitiveDataLogging(true);
}
}
}
2022-01-28 15:33:08 -05:00
}