0

I have and ASP.NET MVC website working fine with my SQL 2016. I mean there is no problem with ConnectionString in the web.config file!

But the problem is where I add-migration and wanna to Update-Database via Package Manager Console.

I get this 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)

What can cause? the connection string is 100% correct! the SQL server is working with live app!

why couldn't EF connect to that?

.NET Framework version: 4.7.2 SQL Server version : 2016 OS: Windows 10

Hamed Zakery Miab
  • 738
  • 2
  • 12
  • 34

1 Answers1

0

Are you using DataLayer. If you using Update-Database command at DataLayer (look for Default Project at top of Package Manager Console) you should add your connectionstring to DataLayer's app.config file.

EDIT;

Update-Database -Verbose 
 -ConnectionString "CONNECTIONSTRING" 
 -ConnectionProviderName "System.Data.SqlClient"
 -StartupProjectName WEBSITE_PROJECT -ProjectName MIGRATION_PROJECT
Mehmet
  • 1,824
  • 3
  • 19
  • 28