Skip to content

May 2, 2014

3

Upgrading from ASP.NET.Identity 1.0 to 2.0

by adamstephensen

ASP.NET.Identity 2.0 is out, and it adds a bunch of great features.

– Two-Factor Authentication (SMS, Email or custom)
– Account Lockout
– Account Confirmation via Email
– Password Reset
– Sign out everywhere
– Choose your Primary Key type (string, int, Guid)
– IQuerable Users and Roles
– Delete User
– Enforcing Unique User Names

 

The upgrade was more fiddly than I thought it would be. Here is what I had to do. I hope it helps.

 

1. Update Entity Framework to 6.1

2: Update all your OWIN components if they already exist in your project.

(Yes. NuGet should handle this for me. It didn’t. Upgrading the Owin components before the Identity packages resolved some issues for me)

image

 

3: Update Microsoft ASP.Net Identity Core and then ASP.Net Identity EntityFramework

image

 

4: Your model has now been updated to v2.0 !

If you are running Code First Migrations you now need to create a migration to reflect the changes to the database.

image

Figure: When you try to create the migration, it will tell you that the model backing the db context has changed. To resolve it, you need to update the constructor of your dbcontext.

 

image

Figure: Adding ‘, throwIfV1Schema:false’ as a parameter to the constructor will allow you to run the application, and create the required Code First Migration.

 

image

Figure: After updating the db context constructor, Add-Migration works as expected.

 

image

Figure: You can now inspect the changes to the schema in the Migration.

Upgraded !

Now check out the links below to get help on how to implement the great new features in ASP.Net Identity 2.0.

 

Resources:

ASP.NET MVC and Identity 2.0: Understanding the Basics

http://typecastexception.com/post/2014/04/20/ASPNET-MVC-and-Identity-20-Understanding-the-Basics.aspx

– a great overview of Identity 2.0

 

Announcing RTM of ASP.NET Identity 2.0.0

http://blogs.msdn.com/b/webdev/archive/2014/03/20/test-announcing-rtm-of-asp-net-identity-2-0-0.aspx

– definitely worth reading !

– contains list of features and some upgrade notes

Advertisements
3 Comments Post a comment
  1. Kristofer
    May 8 2014

    Hi, this was really useful! But I have a problem – instead of RenameColumn, AddColumn or some other command I have only CreateTable commands in my Up method and DropTable and DropIndex in my Down method. This leads to a conflict, because it tries to create a table before it had deleted it. Any ideas how to fix this? Thank you in advance! 🙂

    Reply
  2. あなた本当にプレゼンテーションしかし | | 本当に簡単そう簡単それは見えるようです作るI 見つけるこのトピック 私は希望私は信じ 何か 私がかもしれない 決して理解しています。 複雑な複雑と 非常に ワイド私のために。公開| |提出| 先に前進 外観を持つ 、それをぶら下げる|しがみつく|把握|ホールド|} 私は {しようとするでしょう!
    最安値定番 完売これで最後 http://saunadveri.ru

    Reply

Trackbacks & Pingbacks

  1. Upgrading #ASPNET #Identity in #NuGet | Michael Earls

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments