Error updating DB network interfaces: SQL, error: 26 - Server / instance location determination error

I use EF6 and make some changes to my model. Now all of a sudden, I get the following error when trying to update my database using the nuget Update-Database command:

An error has occurred with the network or a specific instance while establishing a connection to SQL Server. The server was not found or was unavailable. Verify that the instance name is correct and SQL Server is configured for a remote connection. (provider: SQL Network Interfaces, error: 26 - Server / instance localization error Indicated)

I did not change anything in the connection settings (or in general in web.config), but here is 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 BrowserData Links I can access the database without any problems.

What could be the problem? I tried to delete the database using SQL Server Object Browser , but I still get the error.

People still need help. It would be very helpful if someone could help me - I tried everything I could!

+5
source share
4 answers

This is because the migration project is not a StartUp project, which means that you need to set the connection string in the StartUp project so that it works correctly.

Hope this helps. Best wishes.

+7
source

I had the same problem. In my case, the connection string is read from the web project, not the EntityFramework project, so I made the Solution StartUp web project project so that the console package manager can read the connection string and in the console package manager I selected the EntityFramework project as the default project.

+4
source

Follow the steps: 1./ Create the right to connect to the database in web.config 1./ Right-click → select "Set as default project" 2./ run update-database againt

This is a fix.

+1
source

A similar error can occur if there are several projects in the solution. Run update-database - Verbose and verify that the default project in the package manager console and the StartUp project in the solution explorer are installed in the project that contains the code migration.

0
source

Source: https://habr.com/ru/post/1203498/


All Articles