This is not a duplicate question. I search all of stackoverflow for the answer. If it a duplicate, please point me to question that answers this. The answers I found do not solve the issue.
I have developed a website with c# code behind with the connection string as follows: In the webconfig of the asp.net website and and in the app.config of the service:
<connectionStrings>
<add name="UsersConnectionString" connectionString="Data Source=
(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\[database].mdf;
Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
In both c# code behind and service I have the following:
SqlConnection connSN = new
SqlConnection(ConfigurationManager.ConnectionStrings
["UsersConnectionString"].ConnectionString);
When I try to launch my service, I get the following:
Additional information: An attempt to attach an auto-named database for file mydatabase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
How can I attach to the database with multiple services AND asp.net code behind?