using Microsoft.EntityFrameworkCore;

namespace RobotNet.RobotManager.Data;

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

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

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