Archive for August, 2008

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!

How To: Fix ‘YMSGR’ is Undefined

My .NET Framework 3.5 SP1 wasn’t a smooth one as I had to go through different levels of cleaning up .NET framework installation registries before I can install it. On top of that, I also had to remove previous components of pre-SP1 release as these might conflict with the installation.

After all the hullabaloo, I shutdown my machine and returned to work the next day. To my dismay, after successfully logging on to Yahoo Messenger, I can accept messages from contacts (and non-contacts/spam) but I can’t read their messages. It took me a while to recognize the problem. I tried uninstalling/reinstalling the program but that failed.

Solution:

Running through the Microsoft Script Debugger, I found out that the chat window is some sort of HTML page enclosed within the program. That chat window have some scripts included so I guess that it follows the DOM that IE follows. So, I have to use one button I often see in IE options but never dared to click on it. No wonder, that’s the only button I had to click to clear that error.

Hope this helps. Though it still keeps me wondering if the SP1 installation has triggered this error. Everything has been fixed but I have to reinstall the IE developer toolbar, as well as the “Web Development Helper” toolbar of Nikhil Kothari.


Tags

Blog Stats

  • 2,757 hits

 

August 2008
S M T W T F S
« Jul   Oct »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Follow

Get every new post delivered to your Inbox.