Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Clear dbcontext after loading a (new) vault from server (#906)

Leendert de Borst37d6ead41dfa
diff --git a/apps/server/AliasVault.Client/Services/Database/DbService.cs b/apps/server/AliasVault.Client/Services/Database/DbService.cs
index bb05a1c36..d9b5b1d3a 100644
--- a/apps/server/AliasVault.Client/Services/Database/DbService.cs
+++ b/apps/server/AliasVault.Client/Services/Database/DbService.cs
@@ -608,6 +608,9 @@ public sealed class DbService : IDisposable
string decryptedBase64String = await _jsInteropService.SymmetricDecrypt(vault.Blob, _authService.GetEncryptionKeyAsBase64Async());
await ImportDbContextFromBase64Async(decryptedBase64String, _sqlConnection!);
+ // Refresh the db context with the new database to invalidate any cached data if the _dbContext was already used.
+ _dbContext = new AliasClientDbContext(_sqlConnection!, log => _logger.LogDebug("{Message}", log));
+
// Check if database is up-to-date with migrations.
var pendingMigrations = await _dbContext.Database.GetPendingMigrationsAsync();
if (pendingMigrations.Any())