Search code examples
entity-framework-4sql-server-cedatetime2

How can I make my EF4 entities use the datetime2 type with SQL Server CE 3.5?


I would like to store DateTime values using the datetime2 type in SQL Server CE 3.5.

If this is possible, how would I change my entity data model? I've tried editing it manually and Visual Studio refuses to show it in the designer afterwards.


Solution

  • datetime2 does not exist is SQL Server Compact, in order to save datetime2 values, you must save in a nvarchar(27) value of the form 'YYYY-MM-DD hh:mm:ss.nnnnnnn' (see http://msdn.microsoft.com/en-us/library/ms171931.aspx)