public async Task <int> RemoveMissingAccountsAsync(IEnumerable <Account> accounts) { var existingAccounts = GetAllDbAccounts(); var nonExistingAccounts = existingAccounts .Where(ea => !accounts.Any(a => a.Id == ea.Id)) .ToList(); _accountContext.RemoveRange(nonExistingAccounts); _logger.LogDebug($"Removed {nonExistingAccounts.Count} accounts"); await _accountContext.SaveChangesAsync(); return(nonExistingAccounts.Count); }