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.
Appart from changing the ProviderManifestToken from 2008 to 2005, in my case was also needed to update the properties type from ‘date’ to ‘datetime’.
i love you. thanks.
Outstanding! This is exactly the problem I just had and the solution was fast and effective. Thanks!
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 ;)
This was VERY helpful, you save me a lot of time. I also have SQL 2008 in my Dev and SQL 2005 in production.
I love the intertubes!
whatever your problem, someone else has had it, and blogged the solution!
Many thanks – keep up the good work!
Thanks man! You really made my day :D
Loving you. Many thanks!
Saved me hours, thanks!
Saved me from a world of hurt!
Thanks for the solution!
Thank you!!!
I love you too.
Thank you one more time.
Where do you find the EDMX file, unfortunately you don’t say. Thank you for adding this detail.
Thanks for the solution
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?
Excellent post!!!
Thanks, very helpful. :)