server-master/srcs/_plugins/Plugin.DB.EF/Extensions/GameContextFactoryExtensions.cs
2026-02-10 18:21:30 +01:00

32 lines
No EOL
815 B
C#

// WingsEmu
//
// Developed by NosWings Team
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using PhoenixLib.Logging;
using Plugin.Database.DB;
namespace Plugin.Database.Extensions
{
public static class GameContextFactoryExtensions
{
public static async Task<bool> TryMigrateAsync(this IDbContextFactory<GameContext> contextFactory)
{
await using GameContext context = contextFactory.CreateDbContext();
try
{
await context.Database.MigrateAsync();
Log.Info("DATABASE_INITIALIZED");
}
catch (Exception ex)
{
Log.Error("DATABASE_NOT_UPTODATE", ex);
return false;
}
return true;
}
}
}