Skip to content

Auto Apply Migrations

Inside the Program.cs file, add the following code:

using (var scope = app.Services.CreateScope())
{
    var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
    await db.Database.MigrateAsync();
}