I don't understand how to make LocalDB show up in the SQL Server Object Explorer. On some VMs, it shows up automatically, on some other VMs, it doesn't. Still, after googling for hours, I don't get it.
The error says:
System.Data.SqlClient.SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.) ---> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
So, on this VM, no database gets created and nothing shows up in the SQL Server Object Explorer's SQL Server
node.
C:\Users\<username>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB
; but on this VM, there is no such folderApp.config
looked every time like this (and it was automatically created that way when I installed Entity Framework 6 the NuGet Package Manager in Visual Studio):<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
SQLException
I had the same issue today recently installing VS2015 Community Edition Update 1.
I fixed the problem by just adding the "SQL Server Data Tools" from the VS2015 setup installer... When I ran the installer the first time I selected the "Custom" installation type instead of the "Default". I wanted to see what install options were available but not select anything different than what was already ticked. My assumption was that whatever was already ticked was essentially the default install. But its not.
To check if LocalDb is installed or not:
cmd
and type in sqllocaldb i
this should give you the installed sqllocaldb instances if found.(localdb)\V11.0
using windows authentication.If an error is raised Cannot connect to (localdb)\V11.0.
change the instance name to (localdb)\MSSQLLocalDB
and try again to connect, if you still get the same error.
Follow these steps to install LocalDb:
Start Menu
and type in search sqlLocalDb
.sqlLocalDb.msi
and click it.after finishing the installation re-run SSMS
and try connecting to either of the instances (localdb)\V11.0
or (localdb)\MSSQLLocalDB
, one of it should work depending on what Visual Studio version you have.
You can also verify that localdb
is installed using Visual Studio by simply creating new sql file and go to the connect icon on the top header of the file which by default lists all the servers you can connect to including localdb
if installed.
In addition to the above mentioned ways of finding if localdb is installed, you can also use the MS windows power shell
or windows command processor CMD
or even NuGet package manager console
on your server machine and run these commands sqllocaldb i
and sqllocaldb v
that will show you the localdb name if it is installed and the MSSQL server version installed and running on your machine.
If you are not sure if local db is installed, or not sure which database name you should use to connect to it - try running 'sqllocaldb info' command - it will show you existing localdb databases.
Now, as far as I know, local db should be installed together with Visual Studio 2015. But probably it is not required feature, and if something goes wrong or it cannot be installed for some reason - Visual Studio installation continues still (note that is just my guess). So to be on the safe side don't rely on it will always be installed together with VS.
Select your database and ready to go.
I tried to install only LocalDB, which was missed in my VS 2015 installation. Followed below URL & selectively download the LocalDB (2012) installer which is only 33mb in size :)
https://www.microsoft.com/en-us/download/details.aspx?id=29062
If you are looking for the SQL Server Data Tool for Visual Studio 2015 Integration, then Please download that from :
On your command prompt type sqllocaldb start
Use <add name="defaultconnection" connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=tododb;Integrated Security=True" providerName="System.Data.SqlClient" />
My App.config looks as below:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
I noticed that there is localDB in the path that you mentioned above and has the version v11.0. So I entered (LocalDB\V11.0) in Add Connection dialogue and it worked for me.
Another solution (at least for VS2019) if you dont know your localdb ServerName:
Tools => SQL Server => New Query
And in popup just select Local and there you should find Server name(and more) for your localdb
User contributions licensed under CC BY-SA 3.0