Friday, December 2, 2011

Entity Framework - The provider did not return a ProviderManifestToken string

Recently I was working on data access code using the Entity Framework 4.1 and Code First.  I had a simple DbContext setup. Everytime I would add an object to one of the DbSets I created, I got this exception:

The provider did not return a ProviderManifestToken string.

The provider manifest token is part of the SSDL that tells the Entity Framework (and specifically the EF database provider) what version of the DB is being used.    The problem is, since I was using code first, I didn't have an SSDL file.

Digging into the inner exception, I saw this message:

Could not determine storage version; a valid storage connection or a version hint is required.

Also not very helpful.  Google wasn't much help either.  It seems that these two errors (either in pairs or together) can be caused by things like permission errors and database configuration errors. None of them were the cause of this error in my case.

But after digging further, I finally realized that I had a typo in my connection string.  I had DataSource= instead of Data Source=, i.e. no space.  So, since this error seems to be another famously unhelpful error from Microsoft, I'll throw this suggestion out there to help you if you're running into the same issue.







3 comments:

  1. This was driving me crazy. i had specified the wrong instance in my connection and it also gave this error which is very misleading.

    Saved my sanity! thanks

    ReplyDelete
  2. Thanks a lot for your post man.. it saved lots of my time. Same thing was happend with me. There was no space between "Initial Catalog" in web.config file....

    Your post gave me a quick solution to sort out my problem.. Thanks a lot...

    ReplyDelete