Question

I had an MVC4 project designed using VS2012 which I migrated to MVC5. I am not using OAuth or external logins in my project.

I am now in a dilemma because my old project used the default Simple Membership and related database schema. But now I am migrating to a newer version, and the default database schema is very different.

I can use my custom tables but need help with migrating my users. Since the database membership schema is different I am really confused and don't know how to go about it. The only thing I can think about is regenerating user password and emailing them to my users and hoping that they read the email.

Is there any other way/method I can use to migrate my users to new database schema without fiddling with their passwords?

Was it helpful?

Solution

In VS 2013, when you create a File-->New Project-->MVC, the default authentication mechanism is set to Individual User Accounts which in turn creates a project using the new ASP.NET Identity stuff.

This turns out to include a bunch of new libraries such as:

  • Microsoft.AspNet.Identity.Core.dll
  • Microsoft.AspNet.Identity.EntityFramework.dll
  • Many other dlls

In addition, the project template also adds a new IdentityModels.cs file within the Models folder.

Looking at that file, you’ll notice an ApplicationUser class that implements IdentityUser.

There is also an ApplicationDbContext etc... Looking inside the AccountController, you’ll see a UserManager property.

All of this new stuff is what is related to the new ASP.NET Identity


If you were to create a new project but this time, change the authentication mechanism to No Authentication you’d notice that none of the new ASP.NET Identity stuff is in there.


In VS 2012, when you create a new project and select Internet Application, by default it will use SimpleMembership thanks to the WebMatrix.Data and WebMatrix.WebData dlls (that are not present inside an MVC 5.0 application by the way).

In addition, if you look at the AccountController, you’ll notice the [InitializeSimpleMembership] action filter which triggers the creation of your database.


So far I haven’t answered your question but my understanding (and I do have to mention that I have not tried or tested this) is that you could continue to use SimpleMembership within an ASP.NET MVC 5.0 application as long (of course) as you’re not including any of the ASP.NET Identity stuff previously mentioned.

When you say “I am migrating to a newer version” do you mean that you’re simply updating the version of the MVC dll’s?

OR

Do you mean that you are now using the new ASP.NET Identity stuff and you are now looking for a way to migrate your users from the SimpleMembership to the new Identity TABLES?

Like I said, I have not tried migrating from MVC 4.0 to 5.0 but if I had to do it, I would only upgrade the MVC dll’s and other stuff here and there WITHOUT touching or adding anything relevant to ASP.NET Identity.

I would continue to use SimpleMembership.

Not sure if this will help (or not) but this is my understanding of things.

Otherwise, you may want to have a look at this post

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top