Upgrading to .NET Core 3.1: Replacement for UserManager.NormalizeKey method?

559 views Asked by At

I'm updating an ASP.NET Core project from 2.2 to 3.1. I've sorted out everything else using the migration docs, but it looks like UserManager<TUser>.NormalizeKey(String) has just disappeared after v2.2, and I can't find any migration docs around it.

From what I can tell it does not seem necessary to use. But I'm not sure and we have it sprinkled around everywhere.

For posterity, the error is: The name 'NormalizeKey' does not exist in the current context

My code is something like:

public virtual async Task<IdentityResult> AddToRequestedRoleAsync(ApplicationUser user, string role)
{
  if (user == null) {
    throw new ArgumentNullException(nameof(user));
  }

  var normalizedRole = NormalizeKey(role);
}
1

There are 1 answers

1
Jakob Christensen On BEST ANSWER

In later versions of .NET Core, NormalizeKey has been replaced by NormalizeEmail and NormalizeName.

You may not need to normalize, since FindByEmailAsync will normalize the parameter for you.