public Task StoreAsync(PersistedGrant token) { try { var existing = _context.PersistedGrants().SingleOrDefault(x => x.Key == token.Key); if (existing == null) { _logger.LogDebug("{persistedGrantKey} not found in database", token.Key); var persistedGrant = token.ToEntity(); _context.Add(persistedGrant); } else { _logger.LogDebug("{persistedGrantKey} found in database", token.Key); token.UpdateEntity(existing); _context.Update(x => x.Key == token.Key, existing); } } catch (Exception ex) { _logger.LogError(0, ex, "Exception storing persisted grant"); } return(Task.FromResult(0)); }