Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when updating DB: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

I'm using EF6 and have been making a few changes to my model. Now all the sudden I get the following error when trying to update my database through the nuget command Update-Database:

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)

I did not change anything in my connection settings (or web.config in general) but here's my connection string:

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\LM.DataAccess.mdf;Initial Catalog=LM.DataAccess;Integrated Security=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

In Server Explorer -> Data Connections I can access the database without any problems.

What could be the issue here? I tried deleting the database through the SQL Server Object Explorer but I still get the error.

Still need help people. Would really appreciate if someone could help me out - I've tried everything I could!

like image 380
user3397240 Avatar asked Sep 26 '14 18:09

user3397240


People also ask

What does host Error 26 mean?

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)

Could not connect to server a network related or instance specific error occurred?

This error usually means that the client can't find the SQL Server instance. This issue occurs when at least one of the following problems exists: The name of the computer hosting SQL Server is incorrect. The instance doesn't resolve the correct IP.

How do I allow SQL Server to accept remote connections?

Using SQL Server Management StudioIn Object Explorer, right-click a server and select Properties. Select the Connections node. Under Remote server connections, select or clear the Allow remote connections to this server check box.


2 Answers

Thats caused when your migrations project is not the StartUp project, which means you'll need to set the connectionstring in the StartUp project for it to work correctly.

Hope it helps. Best Regards.

like image 54
Victor Pascoal Souza Avatar answered Sep 29 '22 07:09

Victor Pascoal Souza


I had the same problem, In my case the connection string is being read from the web project not the EntityFramework project, so i made the my Web project the Solution StartUp project so the Package Console Manager can read the connection string, and in Package Console Manager i choosed EntityFramework project as Default project.

like image 25
Abou-Emish Avatar answered Sep 29 '22 08:09

Abou-Emish