Monday, July 5, 2010

An attempt to attach an auto-named database ... aspnetdb.mdf failed.

I had an issue trying to open the aspnet membership database on IIS over the weekend. I would get the following error.
An attempt to attach an auto-named database for file C:\Users \administrator.WESTCHASE\Documents\Visual Studio 2010\Projects\ClaimsEnableWebSite2\ClaimsEnableWebSite_STS\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.

And the fix is simple. This was the connection string I was using when I was getting the error. add name="LocalSqlServer" connectionString="data source=.\;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"

and all that I had to do was add Database=aspnetdb to the connection string.

No comments: