mirror of
https://github.com/ChronosX88/InstructorsListAppTA.git
synced 2024-12-04 14:42:18 +00:00
[backend] feat: Add database initialization
This commit is contained in:
parent
b2703ab1d6
commit
1025dee279
10
Startup.cs
10
Startup.cs
@ -32,8 +32,6 @@ namespace InstructorsListApp
|
||||
{
|
||||
configuration.RootPath = "ClientApp/dist";
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@ -73,6 +71,14 @@ namespace InstructorsListApp
|
||||
spa.UseProxyToSpaDevelopmentServer("http://localhost:4200");
|
||||
}
|
||||
});
|
||||
|
||||
// initialize database
|
||||
var serviceScopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();
|
||||
using (var serviceScope = serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = serviceScope.ServiceProvider.GetService<DatabaseContext>();
|
||||
dbContext.Database.EnsureCreated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user