Last post May 11, 2020 08:37 AM by jiadongm
May 10, 2020 12:42 PM|Rob warning|LINK
Hi, I am creating an Asp net core 2.2 application for witch I need to update my database frequently. I used to do this with Migrations (add-Migration and update-Database ). But lately I get an error message when I try to use the Update-Database migration
command, saying: 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)
My guess is that this has to do with the fact that I added a singleton Database reference in my Startup.cs file (see microsoft forum: https://forums.asp.net/t/2165973.aspx?Dependency+injection+in+HostedService+failing.
The database reference did not change and the 'normal' database access is still working without problems. I can workaround this problem by using an backup from before this implementation, and apply the migration on this backup. but things are getting rather
messy this way.
My question : is this a known problem with migrations? if so what is the solution to fix it? if not a known problem, can somebody tell me where the update-database migration command gets its database reference from?
May 10, 2020 04:56 PMemail@example.com|LINK
Basically "A network-related or instance-specific error occurred while establishing a connection to SQL Server. " This error will come when you are not able to reach the DB Server. To troubleshoot the issue check the connectivity from our application
server /dev env with --> telnet dbserverip 1433 . 1433 is the default SQL Server Listener IP . This will give you some idea .
May 10, 2020 05:37 PM|Rob warning|LINK
thanks for your answer Asprabahar, Unfortunatly your answer is not relevant since the application itself for witch I need the Migration is connecting good to the database. so the connection string is correct and also the database context.
May 11, 2020 08:37 AM|jiadongm|LINK
I found a similar question
here. Make sure that the project is set as startup project.
In addition, there is some information that may be helpful, you can refer to this