Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

Entity Framework SQL Server Version Error

Used Entity Framework 6 in Visual Studio 2015 and pulled all the table from the Development Database I needed.  They changed the Entity Framework SQL Configuration line in the App.Config (.Net Command Line App) and got the following error when trying to insert a record:-
The version of sql server in use does not support datatype 'datetime2'. entity framework

Check my SQL Database tables and I wasn't using DateTime2 in any fields.  OK this is a bit strange, the only difference is that Dev SQL Server is running SQL 2008 R2 and Live is still stuck on SQL 2005.

Fix:-
Right click on the *.edmx (Entity Framework Model) file and select "Open With..."
Select "XML (Text) Editor"
Near the top of the XML there is a section that looks like :-
<Schema Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" 
The catch here is the ProviderManifestToken is still on 2008, so change this to 2005 for SQL Server 2005 and the error should go:-
<Schema Provider="System.Data.SqlClient" ProviderManifestToken="2005" Alias="Self" 
Loading