Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 851
duke Avatar asked Nov 24 '15 09:11

duke


People also ask

What is AspNet core identity?

ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

What is Microsoft AspNet identity Owin?

Microsoft.AspNet.Identity.OWIN. This package contains functionality that is used to plug in OWIN authentication with ASP.NET Identity in ASP.NET applications. This is used when you add sign in functionality to your application and call into OWIN Cookie Authentication middleware to generate a cookie.


1 Answers

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

like image 100
SandRock Avatar answered Sep 30 '22 14:09

SandRock