using Microsoft.EntityFrameworkCore;

namespace RobotNet.MapManager.Data;

public static class MapManagerDbExtensions
{
    public static async Task SeedMapManagerDbAsync(this IServiceProvider serviceProvider)
    {
        using var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();

        using var appDb = scope.ServiceProvider.GetRequiredService<MapEditorDbContext>();

        await appDb.Database.MigrateAsync();
        //await appDb.Database.EnsureCreatedAsync();
        await appDb.SaveChangesAsync();
    }
}
