0

I have recently upgraded Asp.Net Identity V1.0 to V2.0. Because of this, in Identity database few more columns get added like Email, IsEmailConfirmed etc. without any data loss.

I like to know is there any way to downgrade from Asp.Net Identity V2.0 to V1.0 without any data loss.

I have tired many ways but I am not able to retrieve Identity V1.0 database without data loss. Have spend nearly 3 days in search of good tutorial/blog for downgrading activity but not able to find one.

Any help much appreciated.

GOPI KRISHNAN
  • 36
  • 1
  • 6

1 Answers1

0

No source control or backups I assume?

One thing you could possibly do is use code first migrations:

1) Open an Identity Version 1 of your solution. If you can't find one, just do a new project with Identity Version 1.

2) From the console, enable-migrations then add-migration -IgnoreChanges initialIdentity1 followed by update-database. This will create a migration with a snapshot of the current database state.

3) Upgrade to Identity 2.

4) From the console, add-migration identity2update followed by update-database. This will create a migration with the differences including a method called Down() that will contain the information needed to move backwards.

5) Generate a script that can be used to move backwards:

update-database -Script -TargetMigration initialIdentity1

6) Apply that script to your database and downgrade the Nuget Identity package.

Now make a backup and add your code to source control :)

Steve Greene
  • 12,029
  • 1
  • 33
  • 54
  • 1
    It should go without saying (but I'm going to say it anyway). **Make a backup *before* you do anything else** if you care about not losing data. – Bradley Uffner Oct 10 '17 at 13:58
  • @Steve Greene : Identity database tables contain login information of the user. Before up-grading to V2.0 and after up-graded to V2.0 I am able to login with my login credentials. Once I have downgraded to V1.0 I am not able to login with the same credentials. I didn't disturb any data in it. Is there any thing else I need to do? – GOPI KRISHNAN Oct 11 '17 at 12:27
  • Well, I can think of 2 possible causes. You may need to [re-hash the passwords](https://stackoverflow.com/questions/44080599/asp-net-identity-2-0-how-to-rehash-password) or perhaps some of the password rules are different (check return code on failed password to verify). Otherwise the easy way is a restore :) – Steve Greene Oct 11 '17 at 15:50