I need to transfer the asp.net membership data of one website from a sql server database that has entries for several sites to another sql server.
I was looking for some existing/known methods of doing this ? I tried the Web Deploy utility but I could not find any methods of transferring the database records.
Any help would be much appreciated.
Thanks.
The ASP.NET membership database is just a "normal" SQL Server database, so the question is actually "how to transfer a SQL Server database from one server to another, with just a part of the data it contains".
1) Since the database on the old server contains membership information of more than one site, you have to know how to find the data of "your" site (the one you want to transfer) in the database.
I found information about the schema of the ASP.NET Membership database in this tutorial on the ASP.NET site.
Scroll down to "Step 3: A Look at the Schema's Core Tables".
The key information is this, especially the sentences that I made bold:
The
aspnet_Applicationstable is what defines these partitions. Each application that uses the database to store user account information is represented by a row in this table. Theaspnet_Applicationstable has four columns:ApplicationId,ApplicationName,LoweredApplicationName, andDescription.ApplicationIdis of typeuniqueidentifierand is the table's primary key;ApplicationNameprovides a unique human-friendly name for each application.The other Membership- and Role-related tables link back to the
ApplicationIdfield inaspnet_Applications. For example, theaspnet_Userstable, which contains a record for each user account, has anApplicationIdforeign key field; ditto for theaspnet_Rolestable. TheApplicationIdfield in these tables specifies the application partition the user account or role belongs to.
In short: you have to find the site that you want to transfer in the aspnet_Applications table, take the ID from the ApplicationId column and find all rows with the same ApplicationId in all the other tables.
2) Now that you know how to find your site's data in the database, you can move the data to the new server. This is nothing ASP.NET specific, it's just plain SQL Server stuff - you just need to create the same database on the new server, but only with the data for your site.
I can think of two ways to do this:
Way 1:
delete from aspnet_Users where ApplicationID <> 'X'X is the ApplicationID of your site from the aspnet_Applications table)Way 2:
insert into aspnet_Users
select * from [Name_of_old_server].[Name_of_old_database].dbo.aspnet_Users
where ApplicationID = 'X'X is the ApplicationID of your site from the aspnet_Applications table)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With