Entity Data Model generated from SQL 2008 and used with SQL 2005

Ok, this is of course is not a perfect scenario, because ideally my dev and test environments should be identical to my live enviroment. But anyhow, I had some troubles with Entity Framework today. After deployment my WCF services just threw exceptions (have I ever mentioned that I don’t like WCF for making everything including debugging so difficult – but that’s a different story). After I attached the debugger I finally saw what was really throwing my exceptions. It was one of my LINQ statements on the EDM, telling me:

The version of SQL Server in use does not support datatype ‘datetime2’.

Funny, I thought. Since I don’t use datetime2. It’s actually just a model imported from a SQL 2005 database to SQL 2008. But since I had generated it again from the SQL 2008 (or was it just an update, I can’t remember) it must have remembered this fact and now maps the datetime differently?

The solution in case anyone has the same problem is to open your EDMX in a file editor (or “open with…” in Visual Studio and select XML Editor). At the top you will find the storage model and it has an attribute ProviderManifestToken. This has should have the value 2008. Change that to 2005, recompile and everything works.

Hope it helps.

19 thoughts on “Entity Data Model generated from SQL 2008 and used with SQL 2005

  1. Appart from changing the ProviderManifestToken from 2008 to 2005, in my case was also needed to update the properties type from ‘date’ to ‘datetime’.

  2. Outstanding! This is exactly the problem I just had and the solution was fast and effective. Thanks!

  3. THANK YOU!!! I knew the issue was due to developing in a SQL 2008 env and installing with a SQL 2005 env but I couldn’t find the switch. You saved the day ;)

  4. I love the intertubes!
    whatever your problem, someone else has had it, and blogged the solution!

    Many thanks – keep up the good work!

  5. I will attempt to deploy this solution on my dev machine tomorrow. However, I did notice that I am now unable to view/edit the .edmx file in Visual Studio 2010 once I do this.

    VS2010 now displays: “The Entity Data Model Designer is unable to display the file you requested. You can edit the model using the XML Editor.”

    Does anyone have a fix for this?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.