IW4M-Admin/Data/MigrationContext/MySqlDatabaseContext.cs

35 lines
997 B
C#
Raw Permalink Normal View History

using System;
using Data.Context;
using Data.Extensions;
using Microsoft.EntityFrameworkCore;
namespace Data.MigrationContext
{
public class MySqlDatabaseContext : DatabaseContext
{
public MySqlDatabaseContext()
{
if (!MigrationExtensions.IsMigration)
{
throw new InvalidOperationException();
}
}
public MySqlDatabaseContext(DbContextOptions options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (MigrationExtensions.IsMigration)
{
2022-02-22 18:09:50 -05:00
var connectionString = "Server=127.0.0.1;Database=IW4MAdmin_Migration;Uid=root;Pwd=password;";
optionsBuilder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))
2022-01-26 11:32:16 -05:00
.EnableDetailedErrors()
.EnableSensitiveDataLogging();
}
}
}
2022-01-26 11:32:16 -05:00
}