Migrate database on startup
This commit is contained in:
parent
4e99b648ff
commit
3ab458101a
1 changed files with 5 additions and 0 deletions
|
@ -162,6 +162,11 @@ app.UseEndpoints(endpoints =>
|
||||||
endpoints.MapControllers();
|
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"))
|
if (!Directory.Exists("Upload"))
|
||||||
Directory.CreateDirectory("Upload");
|
Directory.CreateDirectory("Upload");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue