Moeez
Moeez

Reputation: 478

Unable to connect to SQL Server Express in visual studio 2019

I am trying to connect to my SQL Server Express using migration. The migration is successful but while updating I am getting an error.

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: 26 - Error Locating Server/Instance Specified)

appsetings.json

{
"Logging": {
"LogLevel": {
  "Default": "Information",
  "Microsoft": "Warning",
  "Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DemoLoginContextConnection": "Server=(DESKTOP-48LBLF\\SQLEXPRESS)\\mssqllocaldb;Database=DemoLogin;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}

SSMS

enter image description here

Upvotes: 1

Views: 925

Answers (1)

marc_s
marc_s

Reputation: 754478

As your screenshot shows - the server/instance name should be just DESKTOP-48LBLF\\SQLEXPRESS - not what you have right now....

Try this:

"ConnectionStrings": {
    "DemoLoginContextConnection": "Server=DESKTOP-48LBLF\\SQLEXPRESS;Database=DemoLogin;Trusted_Connection=True;MultipleActiveResultSets=true"
}

Upvotes: 3

Related Questions