David Rogers
David Rogers

Reputation: 83

Visual Studio 2022 can connect to localdb but SSMS 18.10 can't

Spanking brand-new installations of:

There are no other Visual Studio or SQL Server instances or installations.

A console program creates a localdb database using Entity Framework successfully. VS SQL Server Object Explorer documents this with a connection to (localdb)\MSSQLLocalDB using a connection string of:

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;
    Integrated Security=True;Connect Timeout=30;Encrypt=False;
    TrustServerCertificate=False;ApplicationIntent=ReadWrite;
    MultiSubnetFailover=False

But I can't get SSMS to connect to this localdb database instance.

I am trying to use this server name:

(localdb)\MSSQLLocalDB

What am I doing wrong? I get an immediate (2 second) response with:

The instance of SQL Server you attempted to connect to does not support encryption. (.Net SqlClient Data Provider)

I used sqllocaldb, and everything looks ok:

sqllocaldb info
MSSQLLocalDB
ProjectModels

sqllocaldb info MSSQLLocalDB
Name:               MSSQLLocalDB
Version:            15.0.4153.1
Shared name:
Owner:              GreenMachine\jean
Auto-create:        Yes
State:              Running
Last start time:    1/21/2022 11:38:11 AM
Instance pipe name: np:\\.\pipe\LOCALDB#878B8E4E\tsql\query 

So I tried another tack. I pointed my EF connection string to the local SQL Server instance:

 optionsBuilder.UseSqlServer("Data source = GreenMachine; Initial 
 Catalog=SamuraiAppData; Integrated Security=True; 
 TrustServerCertificate=True;")

And that worked - I got a new database created on that instance. It seems like SSMS can't connect to localdb!

Thanks for your ideas!

Upvotes: 4

Views: 5298

Answers (2)

LJHW
LJHW

Reputation: 435

I had the same problem after completing an MVC/Entity tutorial and I managed to connect using SQLSMS v19.1 by doing the following.

I used the same 'Server name' as David above:

enter image description here

In Visual Studio, the 'SQL Server Object Explorer' had a 'Connection string' property of:

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False

I accepted all the defaults in SQLSMS but added these to the 'Additional Connection Parameters' tab:

enter image description here

Upvotes: 0

John Glenn
John Glenn

Reputation: 1629

From the SSMS connection dialog, click the Options button in the lower right corner to expand the connection options. Ensure that Encrypt Connection is not checked.

enter image description here

Upvotes: 3

Related Questions