This is quite common error in visual studio – The underlying provider failed on open. When you connect to database in the Sql Server Management studio, it gets connected. But when you try to run your application in visual studio, its throwing Exception like this - The underlying provider failed on Open.
If you view the details of this error it says –
Getting this error is strange as you can connect to the database in the Sql Server Management studio. The error comes when you try to connect to your sql database in visual studio.
I found a very simple solution of this problem. Below I attached the screenshots of the error.
Here is how I solved this problem.
Go to the command prompt either by pressing win key +X and selecting Command Prompt(Admin) or by opening it from list of All programs(Right click on it and select Run As Administrator).
Type the following command :
netsh Winsock reset
After executing this command, the problem was solved for me straightway. However if it not worked for you, restart your PC and try again.
Please note that this error can also come due to many different reasons other than changes winsock.txt file. But mostly you see this error in visual studio due to corrupted winsock file.Give it a try and let me know whether it worked or not.