ASP.NET Membership Database Migration Helper

This is my project born out of a problem on how to backup the existing data that I have on a website. In one of my projects, I have created a user registration system based on ASP.NET Membership although as I reach the peak of the limits of the database hosting, I need a means to transfer the data from that database to another.

Unfortunately, the original database host of my old project didn’t allow me to connect to the database via SQL Server Management Studio and it would be a pain to manually gather the membership information and maintain its integrity particularly the password if the Membership provider configuration for the password is set to “Hashed”.

I tried searching if there’s an API for programaticaly migrating data but I haven’t found one. Solutions found over the net include backing up the database and restore it in a local store but I find that tedious. I need something that is as much as possible with less clicks. With that, this application is an attempt to solve that problem.

Directions:

1. Start with Start.aspx (Default.aspx will eventually redirect you to that page). Provide the following information:

a) Source Database Connection String
b) Source Database Application Name
c) Target Database Connection String
d) Target Database Application Name

a & c are obvious reasons why you need to provide them. “b” is needed since we need to specify what specific application database are we backing up. Typically, the ASPNETDB.mdf file that is being created whenever we fire up the Website Administration Tool (WSAT) can handle users for use with Membership for different web applications by virtue of applicationId. This can be verified by opening the aspnet_Applications table. On the other hand “c” is needed since we need to check that the database doesn’t contain that application name as it might overwrite any existing data in there (in cases you want to merge Membership databases).

2. Clicking validate will validate the information that you have provided. Until such time all entries appear to be valid, then it would only be at that period you can click on the “Export >>” button that will perform the actual migration. Likewise, once validated, you can also delete or clear the target database of all it’s entries.

WARNING:

Be aware only that this action is irreversible and there’s no way of backing it up unless you have a spare copy of that database somewhere else.

3. You would be informed in Result.aspx if the migration is okay or not. TryExport.aspx is actually the page that I made to test if the export is working or not. Before trying it out, do the following:

  • Modify web.config by editing the connection string list and the provider list. Edit the connection string section first as the providers will depend on the entries of this section. This application is by default populated with two providers namely: AspNetSqlMembershipProvider (source) and ExportedDBMembershipProvider (destination). The connection string attribute of the provider should match that of the connection string name of the source/destination databases. Failure to do so will prohibit you from validating if the export works or not.
  • The applicationName attribute of the destination provider should match the “Target Application Name” specified in Start.aspx. Failure to do so will prohibit you again from validating if the export works or not.
  • You can change the name of the providers and will allow you to validate however, you need to change as well the values set in the code-behind of TryExport.aspx for the provider name.

Additional Notes:

  • I tested the code to work when transporting between two SQL Server 2005 Express database files. However, the application might throw an error when the data is too big to transfer.
  • This application just exports the application data, membership information and roles. I am still making a way to include the Profile data (if there’s any) to the exported database.

The file is in zip format but since wordpress is not accepting ZIP files as attachment, you can download it here and rename it to .zip.

Comments, reactions, suggestions? Post a comment here!

Advertisements

0 Responses to “ASP.NET Membership Database Migration Helper”



  1. Leave a Comment

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




Blog Stats

  • 3,922 hits
August 2008
S M T W T F S
« Jul   Oct »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

%d bloggers like this: