ASP.Net Identity EF Users Primary Key Change

misc1Recently, I worked on converting a .Net API from a 3rd party authentication mechanism to internal and we chose to use the Identity framework.  By default, Identity uses a string as the primary key for the AspNetUsers table and that was an issue because our current users table used a long (and there were a lot of foreign key references to it).

Fortunately, the Identity system is quite flexible and, with a few changes, allows for any primary key type.  The following link describes how to accomplish this:

It worked without any major problems, problems.  However, since we were converting over an existing users database, we needed to manually set the EmailConfirmed and the SecurityStamp fields in SQL via:

UPDATE AspNetUsers SET SecurityStamp = NewID(),EmailConfirmed=1




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s