Revize fc0e5b36
Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)
Backend/Backend/Program.cs | ||
---|---|---|
18 | 18 |
builder.Services.AddEndpointsApiExplorer(); |
19 | 19 |
builder.Services.AddSwaggerGen(); |
20 | 20 |
|
21 |
// Database |
|
21 | 22 |
builder.Services.AddDbContext<DatabaseContext>(); |
22 | 23 |
|
23 | 24 |
var app = builder.Build(); |
24 | 25 |
|
26 |
// Enable DateTime in PostgreSQL |
|
25 | 27 |
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
26 | 28 |
|
27 | 29 |
|
... | ... | |
45 | 47 |
using (var scope = app.Services.CreateScope()) |
46 | 48 |
{ |
47 | 49 |
var context = scope.ServiceProvider.GetService<DatabaseContext>(); |
50 |
if (context == null) |
|
51 |
{ |
|
52 |
app.Logger.LogCritical("Could not initialize database context, shutting down."); |
|
53 |
Environment.Exit(101); |
|
54 |
} |
|
48 | 55 |
|
49 | 56 |
// In development we seed dummy data |
50 | 57 |
if (app.Environment.IsDevelopment()) |
Také k dispozici: Unified diff
Changed formatting, added comments, database check