API Traieste
This commit is contained in:
@@ -28,13 +28,13 @@ app.MapControllers();
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
var dbContext = services.GetRequiredService<HealthcareManagerContext>(); // Directly resolving your DbContext
|
||||
var dbContext = services.GetRequiredService<HealthcareManagerDatabase>(); // Directly resolving your DbContext
|
||||
EnsureDatabaseCreated(dbContext);
|
||||
}
|
||||
|
||||
app.Run();
|
||||
|
||||
static void EnsureDatabaseCreated(HealthcareManagerContext dbContext)
|
||||
static void EnsureDatabaseCreated(HealthcareManagerDatabase dbContext)
|
||||
{
|
||||
// Checking for pending migrations is more efficient than applying migrations unconditionally
|
||||
if (dbContext.Database.GetPendingMigrations().Any())
|
||||
|
||||
Reference in New Issue
Block a user