This project is read-only.

deleting claims

Jan 26, 2015 at 10:49 PM
I can successfully add a new claim to the user by doing the following:
  1. user = UserManager.FindByIdAsync(userId)
  2. user.Claims.Add(newClaim)
  3. UserManager.UpdateAsync(user)
However, if I try to delete a claim of a user by doing the similar:
  1. user = UserManager.FindByIdAsync(userId)
  2. user.Claims.Remove(existingClaim)
  3. UserManager.UpdateAsync(user)
Then, an exception is thrown: The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.

My question is: is one supposed to be able to manage a user's claims by operating on IdentityUser<TKey, TLogin, TRole, TClaim>.Claims collection?
Or, must one resort to UserManager.RemoveClaimAsync when it comes to deleting a claim?