I moved my ASP.NET Core 7 MVC project from one computer to another. I did not make any changes in the code. I also moved and restored the database in the same way.
However, I cannot open my project and connect it to SQL Server. I get an error:
Win32Exception: The network path was not found.
Unknown location
SqlException: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
I don't think there is a problem with the database because I was able to create a dummy console app and successfully connect to the database and retrieve the data.
What I tried
- I checked the .net versions on both machines
- I checked the version of the package, uninstalled and reinstalled. tried different connection strings
I think the problem is in the application because when I tried with the console app I connected successfully
This is my connection string:
"ConnectionStrings": {
"db": "Server=localhost;Database=NIFBase;Trusted_Connection=True;"
}
Project packages: https://imgur.com/a/4qR0AQ6
2条答案
按热度按时间tcomlyy61#
Provide what you have in SQL server management studio server name to the appsetting.json
Server=SHADOW
(In this example). Also make sure to addMultipleActiveResultSets=true
at the endof your connection string.kzmpq1sx2#
you are facing connection issues
Create a Database user to access you database and use this connection string