Codekiwi
Just a the musings of a kiwi who loves to code...

This version of SQL Server in use does not support datatype datetime2 EF problem.

Tuesday, February 02, 2010 5:40 PM

Had a strange error come up today when I tried to use my home PC to run an Entity Framework project, the EDMX schema (is it a schema) was generated in SQL Server 2008 and my home dev machine has SQL Server 2005.

I wouldn't have thought this would be a problem as I don't use any 2008 specific features (except the intellisense ;P), but alas I was getting a lot of exceptions from my FunctionImports (stored proceedures in Entity Framework).

Upon investigating the stack trace it was telling me that the DateTime2 datatype was not supported in this version of SQL server, Very strange as I am sure that I do not use the Datetime2 or Date datatypes (these are 2008 specific)
 

This is due to the edmx file being generated or updated from a SQL 2008 instance and run against a SQL 2005 instance. I tried about every trick I could think of before reading about it here. Basically all you need to do is to open the EDMX file with XML Editor and change ProviderManifestToken=”2008” to ProviderManifestToken=”2005”. Thanks a bunch Alex Duggleby for the hint!

From The #Crypt Via Alex Duggleby

Just another thing that I hope will be fixed in the forthcoming EF4.




Feedback

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Thank you so much, solved the issue, i will post the same in my blog. 6/11/2010 2:25 AM | Senthamil

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

I'll second the "thank you".
And join you in hoping I don't have to resort to XML editing in future. 1/24/2011 6:50 PM | Simon

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Thank you. You saved my butt, on last night deployment. :) 1/28/2011 3:27 AM | var

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Would never found out without you. Thanks! 2/4/2011 9:16 PM | cguillemette

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Thanks a lot bother ....... 2/24/2011 6:17 AM | aa

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Hum, this didn't work for me :(
I changed 2008 to 2005, rebuilt the app and still the same error.
EDMX file has more 2008 references inside. Should I change all to 2005? 7/7/2011 11:27 AM | Adi

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Hey, sorry, I take it back. It was an issue related to updating the binaries.
Long story short, it worked! Thanks! 7/7/2011 12:03 PM | Adi

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Thanks so much for this simple fix - you saved me a ton of time debugging why a program that worked in sql 2008 was bombing in 2005. Thanks for posting it! Regards - 9/4/2011 7:21 AM | shawn

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

thanks, cross linking to stackoverflow to make it easier to find both links together. Google had this link at 6 vs stackoverflow at 1.

http://stackoverflow.com/questions/316422/using-sql-server-2008-and-sql-server-2005-and-date-time
9/15/2011 9:18 AM | rusty

# re: This version of SQL Server in use does not support datatype datetime2 EF problem.

Thanks that is exactly what the fix I needed :) 3/5/2012 11:20 PM | Mark vl

Post a comment