duke
duke

Reputation: 1874

how to set username not unique in aspnet identity

I am running into a problem in customizing username table in aspNet Identity. Currently, i am able to login and register with email.After registration,user's Email is filled in email and username column both. now, i know how to seperate these so that username and email both are unique. i have followed this article.http://marcinjuraszek.com/2014/03/asp-net-identity-2-0-0-username-and-email-separation.html I have already customized the primary key from string to int. But, now i want to remove unique constraint on username field also.so that two user's with different email id can have same name ?? I am working on a social application where may be at sometime, the user's count could go up to 100k. then its not possible for every user to have its unique name other than email id. please suggest me how to achieve it ?any article or any suggestion or any way to customize it??

Upvotes: 8

Views: 4438

Answers (1)

SandRock
SandRock

Reputation: 5563

The username column is designed to be used as a unique credential for authentication. See it as an alternative to signing-in with an email address. Because of that, you should not try to use it for another task.

It looks like you are trying to use the username column to store the user's name (as in a full name or pseudonym). Again, this field is not designed for that.

You need to use another mechanism to store the user's name. You may create a new field called DisplayName. You can also use a database table to store extra information.

See How to extend available properties of User.Identity and ASP.NET Identity 2.0: Customizing Users and Roles

Upvotes: 2

Related Questions