I am working on an Entity Framework project using SQL Server 2008. We recently changed to use the datetime2
field type for a lot of our Dates as we need the precision.
This works fine against our live and development databases, but as part of our end-to-end tests we have been using SQL Server CE 4.0, which doesn't support the datetime2
type. The moment Entity Framework tries to construct the database it returns a series of exceptions like this:
error 0040: The Type datetime2 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
Obviously, there is no value in changing our production code for test purposes, so is there a way to tell it to convert the datetime2
values to a regular datetime
or converting them to a varchar
?
The purpose of the test is to ensure that everything from the data layer up to the interface is working as expected, so if there is a better way to implement this kind of test that might provide a useful alternative.