1
votes

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

1
That's an invalid server value - Panagiotis Kanavos
@PanagiotisKanavos I have tried to add a valid one but still it's not working - Moeez
Have you checked services.msc and verified that the SQL Server instance is actually running? - Tieson T.
@TiesonT. yes the sql server is running - Moeez
@Moeez what did you try? The error you got when you tried this invalid connection string doesn't count. There are a lot of duplicate questions for this specific error and the reason is always a wrong server name or an inaccessible server, either because it's not running or because it's blocked by a firewall - Panagiotis Kanavos

1 Answers

3
votes

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"
}