diff --git a/BLAZAM/Pages/Install/InstallDatabase.razor b/BLAZAM/Pages/Install/InstallDatabase.razor index cdb32f18..9ee1aff4 100644 --- a/BLAZAM/Pages/Install/InstallDatabase.razor +++ b/BLAZAM/Pages/Install/InstallDatabase.razor @@ -86,7 +86,7 @@ else await InvokeAsync(StateHasChanged); try { - if (await DbFactory.ApplyDatabaseMigrations(true)) + if (await DbFactory.ApplyDatabaseMigrationsAsync(true)) { Completed = true; await InvokeAsync(StepCompleted.InvokeAsync); diff --git a/BLAZAMDatabase/Context/AppDatabaseFactory.cs b/BLAZAMDatabase/Context/AppDatabaseFactory.cs index 677a967e..328c18e6 100644 --- a/BLAZAMDatabase/Context/AppDatabaseFactory.cs +++ b/BLAZAMDatabase/Context/AppDatabaseFactory.cs @@ -140,21 +140,17 @@ public IDatabaseContext CreateDbContext() : databaseContext; } - /// - /// Applies all pending database migrations - /// - /// : If true, the updates will happen - /// even if the database is seeded. If false, no updates will - /// be applied if seeding has already occurred. - /// - /// - /// If true, the updates will happen even if the database is seeded. If false, no updates will be applied if seeding has already occurred. - /// - public async Task ApplyDatabaseMigrations(bool force = false) + public async Task ApplyDatabaseMigrationsAsync(bool force = false) { + return await Task.Run(() => { + return ApplyDatabaseMigrations(force); + }); - return await Task.Run(() => - { + } + public bool ApplyDatabaseMigrations(bool force = false) + { + + try { using (var context = CreateDbContext()) @@ -187,7 +183,7 @@ public async Task ApplyDatabaseMigrations(bool force = false) Loggers.DatabaseLogger.Error("Database Auto-Update Failed!!!! {@Error}", ex); throw ex; } - }); + } diff --git a/BLAZAMDatabase/Context/IAppDatabaseFactory.cs b/BLAZAMDatabase/Context/IAppDatabaseFactory.cs index e75e0ec0..1ad49133 100644 --- a/BLAZAMDatabase/Context/IAppDatabaseFactory.cs +++ b/BLAZAMDatabase/Context/IAppDatabaseFactory.cs @@ -9,6 +9,16 @@ namespace BLAZAM.Database.Context /// public interface IAppDatabaseFactory { + /// + /// Applies any pending database migrations to the database synchronously + /// + /// + /// You must use true for if you want to apply migrations to an empty database + /// + /// Force the update even if the database is empty and has not been seeded yet + /// + bool ApplyDatabaseMigrations(bool force = false); + /// /// Applies any pending database migrations to the database asynchronously /// @@ -17,7 +27,7 @@ public interface IAppDatabaseFactory /// /// Force the update even if the database is empty and has not been seeded yet /// - Task ApplyDatabaseMigrations(bool force = false); + Task ApplyDatabaseMigrationsAsync(bool force = false); /// /// Creates a new connection to this database ///