How to make an int field named UserID as the primary key in AspNetUsers table in Asp.Net Core 6.0 MVC

Sherpa 181 Reputation points

I am implementing Asp.Net Core Identity on an existing legacy website. I have created the Identity tables using migrations. The legacy database has a table named Users which was used for the logging. I have replaced the Users table with the AspNetUsers table. The legacy table had a field named UserID which was int as well as a primary key. I have modified the AspNetUsers table by adding a field named UserID of type int and moved all the rows from the Users table to the AspNetUsers table. The AspNetUsers table by default has ID field as the primary key which is a GUID. Is there a way to make the UserID the primary key in the AspNetUsers table?

A set of technologies in the .NET Framework for building web applications and XML web services.
4,308 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 26,856 Reputation points

    Identity allows you to configure the primary key. The official documentation covers the details with source code.

    Change Primary Key for Users in ASP.NET Identity