Categories

Meta

Migrating to Identity Core 2.0

Migration to ASP.NET Core Identity 2.0 is an important part of migration to ASP.NET Core 2.0 is. In our case of migration, we had to migrate from “AspNet Full Framework” to “AspNet Core 2.0”. All entities (models) in our case have to inherit from a specific base class and implement a specific interface. So adapting Identity to this, needs special considerations.

IdentityUser generic signature

First shocking change I saw, was IdentityUser. Former one allowed to introduce all other identity entities via its generic signature. Like this:

C#

1

IdentityUser<TKey,TLogin,TRole,TClaim>

But Identity Core has changed it to:

C#

1

IdentityUser<TKey>

It was easy to handle but in first glance it shocked me! This signature is not needed any more. Introducing it in just IdentityDbContext is enough:

New entities and field type changes

Identity Core 2.0 has introduced 2 new entities: RoleClaim and UserToken. Also date time columns in database tables have been changed to datetime2(7). Other changes also happened. For example, Role has 2 new fields, ConcurrencyStamp and NormalizedName.

JWT

Generating JWT seems to be easier than .Net Framework and OWIN. Formerly we have been using:

C#

1

2

3

Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerOptions

Microsoft.Owin.Security.ISecureDataFormat

Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerProvider

While a sample code for generating JWT in ASP.NET Core 2.0 is like this code (inspired from here):