Thursday, October 31, 2013

Entity Framework Model SQL datatype Error System.ArgumentException: The version of SQL Server in use does not support datatype 'datetime2

It is common practice we develop applications in latest environment but in production environment we find a downward configuration which lead us to some strange exception in application. If entity framework (EF) is model is created with SQL Server 2008 there are quite a bit chances you will get some datatype exceptions. The most common one is datetime2.

System.ArgumentException: The version of SQL Server in use does not support datatype 'datetime2

It is very easy to fix just right click on your EF Model and select "Open With" and choose XML Editor from list.


In editor find property ProviderManifestToken its value will be 2008 you can change it to 2005, rebuild your application again and you will see your application will work without any exception on your SQL Server 2005 production environment as well.




No comments:

Post a Comment