How to solve "An attempt to attach an auto-named database for file..." SQL error?

linq-to-sql, sql-server

Solution

I'm going to answer my own question as I have the solution.

I was relying on the automatic connection string which had an incorrect "AttachDbFilename" property set to a location that was fine on the original machine but which did not exist on the new machine.

I'm going to have to dynamically build the connection string since I want this to run straight out of source control with no manual tweaking necessary.

Easy enough.

Problem

I've got a local .mdf SQL database file that I am using for an integration testing project. Everything works fine on the initial machine I created the project, database, etc. on, but when I try to run the project on another machine I get the following: System.Data.SqlClient.SqlException : A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) I figure while I am investigating this problem I would also ask the community here to see if someone has already overcome this. The exception occurs when I instantiate the new data context. I am using LINQ-to-SQL. ``` m_TransLogDataContext = new TransLogDataContext (); ``` Let me know if any additional info is needed. Thanks.

Original source