I've been playing around migrating an existing application running on MVC5 with ASP.NET Identity 2.2.0 having trouble finding proper information, i'd like to ask how you are supposed to do this migration?
I've used a couple of hours on this problem and have found a solution that allows me to log in with Identity 3.0.0-rc1-final with ef7 on my old but migrated database.
I will post what I did as an answer, but i'd very much like inspiration or other ways to have done it.
First I generated a new migration with the following command
This generated two files in the folder Migrations
The snapshot is the same as with ef6, a description of how your database looks. the other file is the actual migration containing the Up and Down commands for migrating your database.
The problems with migrating to the Identity 3.0.0-rc1-final schema appeared to be
And in general the primary key on AspNetUsers and AspNetRole and Foreign Keys to theese tables had changed in length, from 128 to 450
The following is the Up and Down commands I used to be able to log in to my MVC6 application:
Here is an SQL script to convert Identity 2 database to Identity Core (or Identity 3 if you prefer). Notes:
This script was generated by the Visual Studio Schema Compare tool and then modified by hand. The goal of the script is to migrate the schema without dropping the AspNetUsers table. The other tables are dropped and recreated in the process and data is copied. If you have modifications to tables other than the users table or if you have modified the PK of the users table you should modify the script accordingly. There are several changes compared to the default schema related to PK sizes.
The users table has a PK of NVARCHAR(128) as it has in Identity 2 rather than NVARCHAR(450) what Identity 3 uses. All relationship in other tables are also changed to NVARCHAR(128)
The roles table has a PK of NVARCHAR(128). There were several warnings related to maximum key size exceeding 900 bytes for keys including the role id.
There are still some warning related to Login provider having longer keys but I think it is reasonable risk to let the ProviderKey be 450 characters as the actual external provider may use large keys. Note that the default ASP.NET Identity 3 schema has even larger primary keys.
I originally published the script here - https://github.com/Eirenarch/Identity2to3 I might modify this version if I need further changes or discover bugs.