Created
May 24, 2021 11:21
-
-
Save devmobasa/e7f629399e9cbf43df7f99c6273fc30c to your computer and use it in GitHub Desktop.
https://codingblast.com/connect4-live-game-signalr-blazor/ - SignalR Connect4 Blazor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IHost SeedIfNeeded(this IHost host) { | |
using var scope = host.Services.CreateScope(); | |
var services = scope.ServiceProvider; | |
var logger = services.GetRequiredService<ILogger<IDbInitializer>>(); | |
try { | |
logger.LogInformation("Checking if Database is created and if seed needs to be done."); | |
var dbInitializer = services.GetRequiredService<IDbInitializer>(); | |
dbInitializer.Seed().GetAwaiter().GetResult(); | |
} | |
catch(Exception ex) { | |
logger.LogError(ex, "An error occurred while seeding the database."); | |
} | |
return host; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment