I am currently attempting to switch from Entity Framework Automatic Migrations to Code-First Migrations. For a little backstory, this solution is split into four seperate projects: Data, Models, Services, and Web. The connection string information is located in the Web project, and the context is located in the data project.

Now, I have ran "Enable-Migrations", and that appears to have worked correctly.

From there, I delete the existing migrationHistory table in the database.

Running "Add-Migration -projectName Data" will generate an appropriate migration.

The Problem is when I attempt to run Update-Database, it results in a generic 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 can connect to the database using the credentials supplied in the web.config, and the database connections have worked appropriately for the past several months, so I do not believe it is a connectivity problem unless Code-First migrations requires a different port than Automatic Migration.

I assumed that it was just not seeing the connection string supplied in the web.config, however running

"Update-Database -projectName data -startupprojectname web" results in the same error.

My question:

How do I get around the generic network-related error, given the above information? Is this problem a visiblity problem, in which the data project code-first migrations cannot see the connection string in the web project?

Related posts

Recent Viewed