Migrate database on startup

This commit is contained in:
Pat Hartl 2023-08-07 19:06:57 -05:00
parent 4e99b648ff
commit 3ab458101a

View file

@ -162,6 +162,11 @@ app.UseEndpoints(endpoints =>
endpoints.MapControllers();
});
// Migrate
await using var scope = app.Services.CreateAsyncScope();
using var db = scope.ServiceProvider.GetService<DatabaseContext>();
await db.Database.MigrateAsync();
if (!Directory.Exists("Upload"))
Directory.CreateDirectory("Upload");