IW4M-Admin/SharedLibraryCore/Database/MigrationContext/MySqlDatabaseContext.cs

31 lines
862 B
C#

using System;
using Microsoft.EntityFrameworkCore;
namespace SharedLibraryCore.Database.MigrationContext
{
public class MySqlDatabaseContext : DatabaseContext
{
public MySqlDatabaseContext()
{
if (!Utilities.IsMigration)
{
throw new InvalidOperationException();
}
}
public MySqlDatabaseContext(DbContextOptions options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (Utilities.IsMigration)
{
optionsBuilder.UseMySql("Server=127.0.0.1;Database=IW4MAdmin_Migration;Uid=root;Pwd=password;")
.EnableDetailedErrors(true)
.EnableSensitiveDataLogging(true);
}
}
}
}