Entity Framework – Change the SQL database version
Sometime development of ASP.Net websites using the Entity Framework can hit errors, like “System.ArgumentException: The version
of SQL Server in use does not support datatype ‘datetime2′”. This is caused when the EF is setup / configured to run on one version of SQL and is now running against a different version of SQL.
This can be fixed by following these steps:
1. Edit the EF Model XML. This is done by right clicking on the *.edmx file in visual studio and selecting to open wth “XML Editor”.
2. Change the <Schema details and in particular the following attributes
- “
ProviderManifestToken
” – 2008, 2005, 2012 (SQL version) - “Provider” – “System.Data.SqlClient”, “System.Xml” (provider type)
Remember to reduild the solution to make sure the EF recreates the data access code.
Done!