Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of Normalized Email & UserName in .NET core IdentityUser Model?

When I use IdentityUser model in Asp.Net Identity with EntityFramework, it creates some standard fields in the database. All the fields are self explanatory except for the below two fields.

  • NormalizedUsername - Which contains the uppercase value of the Username
  • NormalizedEmail - Which contains the uppercase value of the Email

My doubts are:

  1. Why do we need these Normalized fields? Where does it get used?
  2. What is the purpose of persisting it in the database?
like image 209
Faraj Farook Avatar asked Dec 31 '16 15:12

Faraj Farook


People also ask

What is normalized email?

Normalizing means providing a canonical representation, so that any two equivalent email strings normalize to the same thing. The comments on the Django method explain: Normalize the email address by lowercasing the domain part of it.

What is normalized username?

The name normalization process normalizes a complete username into a base username and a domain. The following forms of usernames are normalized. Some of the common forms for username are: username (no domain) AD-DOMAIN\username.


1 Answers

By my understanding, both fields are there for performance reasons. It's sort of explained in the following thread Normalization on UserName and Email causes slow performance and are used to validate the case insensitive uniqueness of the UserName and Email fields. They are persisted in the database in order be able to create index on them, thus making the lookups by the normalized user name and email sargable.

There is no other reason or usage of these fields.

like image 182
Ivan Stoev Avatar answered Oct 04 '22 04:10

Ivan Stoev