0

I'm trying to connect to an existing database (non-SQLEXPRESS) but everytime I try to access it. I get the following error: The provider did not return a ProviderManifestToken string.

I'm passing a SqlConnection instance to the constructor DbContext(DbConnection, bool) and instantiating the connection in the constructor beacuse I was getting the same error by just passing the connection string. Both of the approaches get the same error.

This is happening on full SQL Server 2008 and 2005.

UPDATE: Read my solution below.

SUMMARY: Always look for the inner exception when you receive The provider did not return a ProviderManifestToken string

Arturo Martinez
  • 3,737
  • 1
  • 22
  • 35
  • 1
    Have you checked the answers in this [SO](http://stackoverflow.com/questions/5423278/ef-4-1-the-provider-did-not-return-a-providermanifesttoken-string) question? – nemesv Oct 27 '11 at 16:42

2 Answers2

1

Just try to open that connection without using EF to validate that connection string is correct and all login information valid because EF sometimes masks these errors with "The provider did not return a ProviderManifestToken" which in such cases means cannot connect to the database.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
0

It seems this was a connectivity problem and whenever entity framework finds a connectivity problem it tells you about it with this brilliant message that doesn't mean anything or is not related to the actual problem. EF might also give you this error on Database Initialization if you don't have access to lookup an existing database where in production this is really easy to happen. Good thing they included the inner exception and I was able to figure this out.

I was able to communicate with the server after enabling SQL Browser service. Something was wrong with the connectivity and starting the service triggered the right functionality. The service is stopped again but the connection is still up.

By the way, the inner exception was: ERROR 40 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: Named Pipes Provider, *error: 40 - Could not open a connection to SQL Server)

Arturo Martinez
  • 3,737
  • 1
  • 22
  • 35