My ASP.NET project has an MDF database in App_Data folder.
The connection string is:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MainDatabase.mdf;Integrated Security=True;User Instance=True
It worked fine until I changed the project parameters to use "Local IIS Web server" instead of "Visual Studio Development Server".
The project now produces the following SqlException
:
An attempt to attach an auto-named database for file C:\Users\Admin\documents\visual studio 2010\Projects\SL\SL\App_Data\MainDatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
How to modify the connection string to make it work with IIS?