Update-Database command giving error in establishing connection to the server (Code First Migration)

213 Views Asked by At

I created this project on my another system and completed. I used code first migration for creating database. On that system, this app was running correctly.

But now when I had transferred the project to another system, Its package manager is showing the following error :

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 tried with Update-Database -Vebrose, I observed that it is targeting wrong data source, which was in that system where I created the project. How to solve this issue?

2

There are 2 best solutions below

1
Bruno On

Check if the app.config has the connection string set. It may have the connection of the "old" machine that is now unaccessible.

0
Bruno On

Is the SQL Server configured to allow remote connections? Is the port 1433 (the SQL Server default port) open?

If you only have the text you sent in the web.config, the connection string might be elsewhere.