localdbsql-server-2012-localdb

Cannot connect to SQL LocalDB on Build Server


My tests were locally working against Local DB using the (localdb)\v11.0 instance when a teammate mentioned we're all on version 12 now and some people on the team might not have v11.

The build server was working fine.

So I changed the connection string to (localdb)\ProjectsV12 and checked all LocalDB versions were on our TeamCity server, they are.

The team is all fine but the build server fails some tests with:

Test(s) failed. System.Data.SqlClient.SqlException : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist. )

It all looks to be setup properly, I can't work out why its failing.

(QA, I know the reason already)


Solution

  • The reason is because (localdb)\ProjectsV12 is an instance that's created by SQL Server Data Tools (SSDT) in Visual Studio and does not exist on the build server.

    Use (localdb)\MSSQLLocalDB in your connection strings instead, that's the proper one for 2014.

    Credit to @ErikEJ in:

    LocalDB SQL Server 2014 Express creates 2 instances (localdb)\ProjectsV12 & (localdb)\MSSQLLocalDB?