I have a asp.net MVC3 project using EF code-first. For my unit testing I have been using SQL Server CE 4.0 and SQL Server 2008 Express. Both have worked perfectly with EF generating my database as expected.
However, when I run my application outside of a unit test and point it at my connection strings I get the error
ProviderIncompatibleException: The provider did not return a ProviderManifestToken string
I have read the MS documentation on this and it appears this is a SqlVersion
token that the EF model generates. The problem is that I am using the code first approach so I have no .edmx
file nor do I know where to point my metadata info to because the db hasn't been generated yet.
I know my connection strings as far as db name, username, and pass are correct because changing them to wrong values throws the expected error. Not sure where to begin.
Thanks.
Here is my connection string:
<connectionStrings>
<add
name="SqlConnection"
providerName="System.Data.SqlClient"
connectionString="Data Source=WORKSTATION\SQLEXPRESS;Initial Catalog=CodeFirst;Integrated Security=False;
Persist Security Info=False;User ID=CodeFirst_user;Password=password1;Connect Timeout=120;MultipleActiveResultSets=True;"/>
</connectionStrings>
I just had this exact problem but I traced it down to my SQL Server service wasn't running. I had just restarted my computer and usually it starts on it's own but didn't for some reason.
Changing to Data Source=localhost worked for me also using MS SQL 2008 R2 Express
Changing the Data Source to
localhost
in theconnectionString
solved my problem.I found, when i provided explicit "User Id=abcUser; Password=somePwd;" in my connection string i am able to resolve the same error. Earlier i was using the "Trusted_Connection=true;", which allowed me to debug my web project, but started giving me error - {"The provider did not return a ProviderManifestToken string."} as soon as i added the Windows azure project and tried debugging the Azure project after adding my web project as a web role under it.
Hope it helps some one experiencing a similar situation.
Thanks, Vivek Bahl
In my case, my connection string name must match the context class name.
Connection String:
Context Class:
After hours of searching & fiddling, I found a way to do it. Turns out the
DbModelBuilder
class takes aDbProviderInfo
in itsBuild
method, so I use that instead of relying on EF to callOnModelCreated
:Obviously this needs some reorganization (e.g. cache the compiled model so you don't need to re-build it every time a context is created).
For me this completely solved the problem. Enjoy!