I am making changes to my database requiring EF migrations for the first time in years. This means that there have been lots of code base changes over the past 2 years, but this is the first time my model has changed for ages. I am using EF 6.1.3, VS 2017 and SQL Express installed on a server on the LAN.
I have EF migrations enabled on the project and am able to "Add-Migration". When it comes to "Update-Database", however, I have 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 am aware that this sort of thing can happen when TCP connections have not been enabled, but I've double checked this and am able to connect to the database with no problems using the same DbContext object and connection string from my application. I can also use SQL Server Object Explorer. It's only Update-Database that fails. I'm on a domain and am using domain-level authentication.
Is there some other permission I need to enable to allow EF Migrations to work?
EDIT: For those who have suggested things like checking the startup project in the comments below, I am providing the start of the error trace. I have not provided the entire trace as that takes us through the whole Migrations Stack of function names. The relevant part including my exact command line is:
PM> Update-Database -ProjectName "AJSoft.CN2.Data.Model" -Verbose
Using StartUp project 'AJSoft.CN2.Data.Model'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'CN2 Test' (DataSource: SERVER\SQLEXPRESS, Provider: System.Data.SqlClient, Origin: UserCode).
System.Data.SqlClient.SqlException (0x80131904): 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)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)
The startup project is the project with access to the connection string and my result is the same whether I specify the "Model" project above or my actual WPF startup project.