using Microsoft.EntityFrameworkCore;

namespace RobotNet.ScriptManager.Data;

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

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

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