diff --git a/Webshop.Api/Program.cs b/Webshop.Api/Program.cs index 7e19010..37cf6f4 100644 --- a/Webshop.Api/Program.cs +++ b/Webshop.Api/Program.cs @@ -64,6 +64,21 @@ builder.Services.AddSwaggerGen(); var app = builder.Build(); +using (var scope = app.Services.CreateScope()) +{ + var services = scope.ServiceProvider; + try + { + var context = services.GetRequiredService(); + context.Database.Migrate(); + } + catch (Exception ex) + { + var logger = services.GetRequiredService>(); + logger.LogError(ex, "An error occurred while migrating the database."); + } +} + // --- START: HTTP REQUEST PIPELINE KONFIGURIEREN --- app.UseForwardedHeaders(new ForwardedHeadersOptions