Deploying aspnetdb.mdf to production server

Hi - I am trying to deploy a simple ASP.NET 2.0 application to a server. The application uses the roles and membership features so that I can make use of the builtin Logon controls. This works fine on my development machine. When I try to run it on my server, I manage to get my logon page, but when I try to logon I get the following error message....

Server Error in '/wms2' Application.
An attempt to attach an auto-named database for file D:\ftp\wms\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I have read through other forums discussing this error, but none seem to be relevant. I am not sure where to proceed from here. Do I need to install Visual Studio on my production server, or is there some sort of SQL Server Express registration required with .NET? I installed SQL Server Express after I deployed my app.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you can change the personalization provider to work with your preferred server rather than the built in express that stores the info in your app_data folder as a *.mdf

You should back up your site first because although it is possible to undo what i am about to describe using the same means, i haven't had much luck.

go to start > programs > microsoft visual studio 2005 > visual studio 2005 command prompt

once that opens type aspnet_regsql.exe and press enter

work your way through the wizard to associate the server you want to use with's personaliztion features like user logins, memberships, and profiles
trevormastersAuthor Commented:
Will this mean that there will be a single database for both environments? I really need to be able to have two independent databases as the production server is at another site. Sharing a database is not an option.  
I'm sorry but i'm not sure i understand what you mean

by default VS 2005 stores the personalization information in the ASPNETDB.MDF file in the App_Data folder.  if you want it to use your preferred database you can follow the steps above.  You can use sql express or whatever to handle your personalization features.  

what this means is that all of the data your application uses will be in one database instead of the database and the *.mdf file.

If you are having trouble migrating the *.mdf file to a remote server, i recommend following the steps above to tell vs 2005 to use it to handle the personalization options.  when you are ready to move it to production use the wizard again to point it to that server.

Hope this helps
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

trevormastersAuthor Commented:
I think it comes down to my lack of understanding of the MDF file and how it is managed/connected. Prior to this, I used an Access database to manage my user accounts and logons. I was expecting the the aspnetdb.mdf file to behave the same way (i.e. just copy it over to the production server and change any relevant connection strings). Am I correct? Or does the MDF file have to SQL Express installed, and you have to somehow tell your app which database to use?

I ran through the wizard (btw, I don't have VS2005 installed in production but aspnet_regsql.exe is in the the .NET Framework directory) and it failed due to permissions so this may be where my initial problem lies.

I will keep at it... I think I just need sleep :)
trevormastersAuthor Commented:
I got there finally.... but it is a work around for my original problem - not the solution. It appears that I SHOULD just be able to copy the ASPNETDB.MDF (and LDF) files to my app and they will be automatically attached to SQL Express. But it doesn't work.

To work around this, I had to manually attach to the aspnetdb.mdf file using SQL Express Manager. The default database name was set to the pathname on my development PC (NOT the actual path on my server) - anyway, that may be irrelevant. I renamed the database name to "MyDatabase".

In IIS, I went to my virtual directory, and loaded up the ASP.NET configuration properties, and replaced the connection string with the following....
Data Source=.\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=MyDatabase

Back to the original problem, is the auto-attach failing because it is looking in the original database path (from my PC), not the new pathname on my server? I.e. it is looking at C:\Documents and Settings\trev\Local Settings....... instead of D:\www\www\App_data\aspnetdb.mdf ?
man your still working on this, what dedication, now you can finally get that sleep you spoke of three hours ago
PAQed with points refunded (500)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.