Michael Whelan

behaviour driven blog

SQL Server LocalDB 2014 Connection String

I spent way too much time today trying to figure out why I could not connect to my newly installed SQL Server LocalDB 2014 instance. I assumed that I could just update my connection string from v11.0 to v12.0 but it seems that Microsoft have changed the naming scheme for this version. Now the automatic instance is named MSSQLLocalDB.

So, for SQL Server 2012 LocalDB, I had this connection string:

<connectionStrings>
    <add name="SchoolContext" 
        connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\ContosoUniversityDB.mdf;Integrated Security=True;" 
        providerName="System.Data.SqlClient" />
</connectionStrings>

For SQL Server 2014 LocalDB the connection string should be:

<connectionStrings>
    <add name="SchoolContext" 
        connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\ContosoUniversityDB.mdf;Integrated Security=True;" 
        providerName="System.Data.SqlClient" />
</connectionStrings>

According to Microsoft

In SQL14, we moved away from the numbering/versioning for the automatic instance and named it "MSSQLLocalDB" instead of "v12.0".

About Michael Whelan

Michael Whelan is a Technical Lead with over 20 years’ experience in building (and testing!) applications on the Microsoft stack. He is passionate about applying agile development practices, such as BDD and continuous delivery, to agile processes. These days his primary focus is ASP.Net MVC Core and Azure. He contributes to a number of open source frameworks through TestStack.

comments powered by Disqus
Google

Google