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.