0

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.

Forget
  • 142
  • 4
  • 14

1 Answers1

1

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){}
E-Bat
  • 4,792
  • 1
  • 33
  • 58
  • I got this now: > 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. – Forget Dec 30 '15 at 16:09
  • Do you have access to the server named WVM002?. Do ping to it and see if it returns. – E-Bat Dec 30 '15 at 16:13
  • Ok, what happens when you try to connect to this same sql instance, WVM002\SQLEXPRESS, through Sql Server Management console? – E-Bat Dec 30 '15 at 16:26
  • WVM002 is a Virtual Machine containing Windows Server 2008. I am able to access it normally. I even created the user sa already and I was able to create a table on my own PC with Visual Studio Server Explorer manually. I must say I didn't use the console, it was the 2014 Management Studio interface. – Forget Dec 30 '15 at 16:29
  • No, I meant from the same IIS host, can you access the server from there? This is a name resolution problem, verify network configuration for your virtual machine (DNS, etc) – E-Bat Dec 30 '15 at 16:46
  • I'm sorry if this isn't it, but I got access in the Management Studio on the host: http://i.imgur.com/NOLQzqy.png – Forget Dec 30 '15 at 17:01
  • I somehow got it to work after changing the port permissions for UDP and TCP. I'll give you answer because you had some good pointers and spent a lot of time with this. Thank you. – Forget Dec 30 '15 at 17:43