AspNetCore.Docs/aspnetcore/security/authentication/identity-primary-key-config...

1.2 KiB

title uid
Configure Identity primary keys data type security/authentication/identity-primary-key-configuration

Configure Identity primary keys data type

ASP.NET Core Identity allows you to easily configure the data type you want for the primary keys. By default, Identity uses string data type but you can very quickly override this behavior.

How to

  1. The first step is to implement the Identity's model, and override the string type with the data type you want.

    [!code-csharpMain]

    [!code-csharpMain]

  2. Implement the database context of Identity with your models and the data type you want for primary keys

    [!code-csharpMain]

  3. Use your models and the data type you want for primary keys when you declare the identity service in your application's startup class

    [!code-csharpMain]