Initial commit

This commit is contained in:
2026-03-14 00:32:26 +01:00
commit 70a35f3985
109 changed files with 62554 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
namespace RolemasterDb.App.Data;
public static class RolemasterDbInitializer
{
public static async Task InitializeAsync(IServiceProvider services, CancellationToken cancellationToken = default)
{
await using var scope = services.CreateAsyncScope();
var dbFactory = scope.ServiceProvider.GetRequiredService<IDbContextFactory<RolemasterDbContext>>();
await using var dbContext = await dbFactory.CreateDbContextAsync(cancellationToken);
await dbContext.Database.EnsureCreatedAsync(cancellationToken);
if (await dbContext.AttackTables.AnyAsync(cancellationToken) || await dbContext.CriticalTables.AnyAsync(cancellationToken))
{
return;
}
RolemasterSeedData.Seed(dbContext);
await dbContext.SaveChangesAsync(cancellationToken);
}
}