/// <summary> /// Generate migrations before running this method, you can use command bellow: /// Nuget package manager: Add-Migration DbInit -context ApplicationIdentityContext -output Data/Migrations333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 /// Dotnet CLI: dotnet ef migrations add DbInit -c ApplicationIdentityContext -o Data/Migrations /// </summary> public static async Task EnsureSeedData(IServiceScope serviceScope) { var services = serviceScope.ServiceProvider; var ssoContext = services.GetRequiredService <JpProjectAdminUiContext>(); Log.Information("Check if database contains Client (ConfigurationDbStore) table"); await DbHealthChecker.WaitForTable <Client>(ssoContext); Log.Information("Check if database contains PersistedGrant (PersistedGrantDbStore) table"); await DbHealthChecker.WaitForTable <PersistedGrant>(ssoContext); Log.Information("Checks done"); var eventStoreDb = serviceScope.ServiceProvider.GetRequiredService <EventStoreContext>(); await eventStoreDb.Database.EnsureCreatedAsync(); }
public static async Task EnsureDatabaseIsReady(IServiceScope serviceScope) { var services = serviceScope.ServiceProvider; var ssoContext = services.GetRequiredService <SsoContext>(); Log.Information("Testing conection with database"); await DbHealthChecker.TestConnection(ssoContext); Log.Information("Connection successfull"); Log.Information("Check if database contains Client (ConfigurationDbStore) table"); await DbHealthChecker.WaitForTable <Client>(ssoContext); Log.Information("Check if database contains PersistedGrant (PersistedGrantDbStore) table"); await DbHealthChecker.WaitForTable <PersistedGrant>(ssoContext); Log.Information("Checks done"); }