2

I've built a MVC WebApp using the ASP.NET 2.0 Core MVC template + Individual User Accounts (EF) and notice that the AspNetUsers table in the database created for my WebApp has a non-unique index for Email whereas the UserName index is unique. Further upon account creation UserName is set to the same value as Email, but the user is then allowed to change their Email using the account management page. I am struggling to understand the rationale here.

I would expect each AspNetUser record to relate to a different person. Therefore why not make Email unique? After all, the email confirmation process expects the address to be unique to the user. However, being non-unique means that user might change their email address to one shared by one or more other users e.g. admin@abc.com. Where is the value in such a use case? Indeed, this is behaviour I want to stop on my site.

Questions:

  1. Would changing the AspNetUser Email index to unique have any consequences or otherwise break the framework?

  2. Would allowing the user to change their UserName have any consequences or otherwise break anything? The primary key of AspNetUsers is Id and seems to used as the foreign key by the other identity tables created by the framework.

  3. Can anyone recommend how to check from the account management page (client side) that a new UserName is unique?

I've found other questions on StackOverflow about this sort of thing, but they don't answer the above questions or explain the rationale

wpqs
  • 657
  • 1
  • 7
  • 18

0 Answers0