using Microsoft.EntityFrameworkCore;

namespace Freman.Sample.Web.Data;

public static class DbMigrationHelper
{
    public static async Task ApplyMigrationsAsync(IServiceProvider services, CancellationToken ct = default)
    {
        await using var scope = services.CreateAsyncScope();
        var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
        await db.Database.MigrateAsync(ct);
    }
}