diff --git a/src/food-market.api/Program.cs b/src/food-market.api/Program.cs index 7a19a34..f152ff2 100644 --- a/src/food-market.api/Program.cs +++ b/src/food-market.api/Program.cs @@ -187,9 +187,10 @@ }); }).RequireAuthorization(); - if (app.Environment.IsDevelopment()) + // Apply migrations on every startup (idempotent). Without this, fresh + // stage/prod deploys land on an empty DB and OpenIddict seeders fail. + using (var scope = app.Services.CreateScope()) { - using var scope = app.Services.CreateScope(); var db = scope.ServiceProvider.GetRequiredService(); db.Database.Migrate(); }