[Webinar] Learn how to a build a cloud-first strategyRegister Now


Deploying aspnetdb.mdf to production server

Posted on 2006-03-27
Medium Priority
Last Modified: 2011-09-21
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.
Question by:trevormasters
  • 3
  • 3

Expert Comment

ID: 16304839
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 asp.net's personaliztion features like user logins, memberships, and profiles

Author Comment

ID: 16305053
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.  

Expert Comment

ID: 16305268
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16305909
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 :)

Author Comment

ID: 16306900
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 ?

Expert Comment

ID: 16307032
man your still working on this, what dedication, now you can finally get that sleep you spoke of three hours ago

Accepted Solution

GranMod earned 0 total points
ID: 16593858
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question