I have my projects setup as follows (repository pattern):
- myProj.Data (Contains the xDB.mdf) [Library]
- myProj.Service (Uses myProj.Data) [Library]
- myProj.WebApp (Uses myProj.Service) [ASP.NET Website]
In 1. I access my Database via Linq to Sql. The app.config looks like this:
<add name="XDbConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\XDb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
When I try to retrieve some data via the web, I get this error thrown from the Service Project:
An attempt to attach an auto-named database for file D:\MyProject\XDb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
From this code:
return (from p in repository.GetPostMedia() where p.PostId == postId select p).ToList();