asp.net-coreidentity

How to remove UserName field from asp.net core 3 Identity


I wanna use phoneNumber field as a unique field and remove UserName Is it possible?


Solution

  • No. You cannot modify the default IdentityUser model. However, you can treat the phone number as the user name, as using email for user name works, i.e. you simply just make it the value of UserName as well. For example, when using email as username, both Email and UserName hold the email address. Simply do the same with your phone number. Make the phone number the value of UserName, and then you're good to go.