Run migrations on startup

This commit is contained in:
Reimar 2025-03-19 13:19:14 +01:00
parent 950f023821
commit 5201e6e474
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268

View File

@ -2,14 +2,14 @@ using Api;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
public class Program var app = WebHost.CreateDefaultBuilder(args)
{ .UseUrls("http://0.0.0.0:5000")
private static void Main(string[] args) .UseStartup<Startup>()
{ .Build();
CreateWebHostBuilder(args).Build().Run();
} await using var scope = app.Services.CreateAsyncScope();
// Calls the startup class and creates the webinterface await using var db = scope.ServiceProvider.GetService<DBContext>();
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => await db.Database.MigrateAsync();
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>(); app.Run();
}