Reputation: 152
I know there are several questions with this problem and I've checked pretty much every single one and I still have the same issue.
I have an API that I published to IIS. However, I can't use the connection string properly it seems, as when I run the update-database command targeting that connection string I get the following error:
System.Data.Entity.Core.ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure. ---> System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> System.Data.SqlClient.SqlException: 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)
This is my connectionString;
<add name="ApplicationDbContext" connectionString="Data Source=WVM002\SQLEXPRESS;Initial Catalog=ImobiliariaARQSI_v01;User ID=sa;Password=password;Persist Security Info = True;" providerName="System.Data.SqlClient"/>
And this is the context:
public ApplicationDbContext() : base("ImobiliariaARQSI_v01", throwIfV1Schema: false)
{
}
I set up the ports on SQL Server on the other machine hosting the instance and it is recognized. The problem is in the connectionstring probably. Help please.
Upvotes: 0
Views: 5957
Reputation: 4892
In the constructor you are passing the dababase name ImobiliariaARQSI_v01, instead of the connection string name as per .config:
public ApplicationDbContext() : base("ApplicationDbContext", throwIfV1Schema: false){}
Upvotes: 2