public async Task <int> AddNewAccountsAsync(IEnumerable <Account> accounts) { var existingAccounts = GetAllDbAccounts(); var newAccounts = accounts .Where(a => !existingAccounts.Any(ea => ea.Id == a.Id)) .ToList(); await _accountContext.AddRangeAsync(newAccounts.Select(na => na.ToDataModel())); _logger.LogDebug($"Added {newAccounts.Count} new accounts"); await _accountContext.SaveChangesAsync(); return(newAccounts.Count); }