Search code examples
c#sqlsql-servervisual-studio-2012localdb

Can LocalDb and SQL Enterprise 2012 run side by side?


I've just installed SQL Enterprise 2012 and now LocalDb appears to be inoperable. I can access LocalDb from the command line and see that the instance that I am referencing is indeed running, but when I run a project with Code First migrations enabled that uses the instance (localdb)\v11.0, I get an error stating that the connection string may be incorrect. I didn't change the connection string at all, it is the connection string that is set by default while creating a new project in Visual Studio 2012.

Has anyone had the same issue? Is there a fix for running both side by side?

Here's the exact error that I am getting:

An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

And the exception:

System.Data.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. ---> System.Data.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> 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.


Solution

  • I just realized what the issue was, hopefully this helps someone else.

    Here is the section of my web.config that was causing errors:

    <entityFramework>
            <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
              <parameters>
                <parameter value="v12.0" />
              </parameters>
            </defaultConnectionFactory>
            <providers>
              <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
            </providers>
    </entityFramework>
    

    The parameter v12.0 value was the issue. It seems that after I installed SQL Server 2012, this generated parameter went from v11.0 to v12.0 causing a version conflict. I guess I could have installed the newest version of SQL Server Express (2014) and not had a problem at all since the version number would indeed be v12.0.