The following works with Visual Studio 2017 Community Edition on Windows 10 using SQLServer Express 2016.
Open a PowerShell check what it is called using SqlLocalDB.exe info
and whether it is Running with SqlLocalDB.exe info NAME
. Here's what it looks like on my machine:
> SqlLocalDB.exe info
MSSQLLocalDB
> SqlLocalDB.exe info MSSQLLocalDB
Name: mssqllocaldb
Version: 13.0.1601.5
Shared name:
Owner: DESKTOP-I4H3E09\simon
Auto-create: Yes
State: Running
Last start time: 4/12/2017 8:24:36 AM
Instance pipe name: np:\\.\pipe\LOCALDB#EFC58609\tsql\query
>
If it isn't running then you need to start it with SqlLocalDB.exe start MSSQLLocalDB
. When it is running you see the Instance pipe name:
which starts with np:\\
. Copy that named pipe string. Within VS2017 open the view Server Explorer
and create a new connection of type Microsoft SQL Server (SqlClient)
(don't be fooled by the other file types you want the full fat connection type) and set the Server name:
to be the instance pipe name you copied from PowerShell.
I also set the Connect to database
to be the same database that was in the connection string that was working in my Dotnet Core / Entity Framework Core project which was set up using dotnet ef database update
.
You can login and create a database using the sqlcmd
and the named pipe string:
sqlcmd -S np:\\.\pipe\LOCALDB#EFC58609\tsql\query
1> create database EFGetStarted.ConsoleApp.NewDb;
2> GO
There are instructions on how to create a user for your application at https://docs.microsoft.com/en-us/sql/tools/sqllocaldb-utility