I have a LINQ to Entities application and a database project for schema management in a VS 2010 solution for .NET 4.0. The object model is currently accessed from the database. One of the tables is defined by a column of type datetime. The database project is configured to use SQL Server 2005 compatibility mode, and so it deploys everything OK.
I just ran into a problem when the update statement using the entity infrastructure uses datetime2 rather than datetime, which throws an exception because SQL 2005 does not support this data type:
System.Data.UpdateException: An error occurred while updating the entries.
See the inner exception for details. ---> System.ArgumentException: The version
of SQL Server in use does not support datatype 'datetime2'.
From the stack trace, it appears that the error appears to be happening inside:
System.Data.Mapping.Update.DynamicUpdateCommand
I looked through all the code and the SQL code and confirmed that there are no references to datetime2 (including the dbschema file). I can only conclude that the data type is generated in a dynamic SQL query generated by the entity infrastructure.
How can I confirm or deny this and how to stop it? The Entity structure does not know that I asked the db project to set the compatibility mode to 2005, and I see no way to tell it the version it is looking at. To do this, I created this project on a machine that has 2008 Express installed, but I periodically switch to another machine that does not (and cannot update yet).
source
share