Page 1 of 1

DateTime to Date/Time

Posted: Fri 23 Mar 2012 11:32
by rogerio.bassete
Hi,

I like maping .net DateTime to Date and DateTime to Time.

Is possible in Code First?

Posted: Mon 26 Mar 2012 16:41
by Shalex
rogerio.bassete wrote:DateTime to Time
It is better to map TimeSpan to Time.
rogerio.bassete wrote:DateTime to Date
As we understood, you want to specify the server data type for the DateTime column. This can be done with ColumnAttribute (the TypeName property: http://msdn.microsoft.com/en-us/library ... .103).aspx ) or, in case of fluent mapping, with the .HasColumnType(string columnType) method of property configuration (an example of application with fluent mapping and detailed description of Code-First peculiarities is available at http://www.devart.com/blogs/dotconnect/ ... qlite.html).

If you already have a database schema and you want just to map classes to it, the easier way to proceed is to create a Code-First model basing on the existing database with http://www.devart.com/blogs/dotconnect/ ... plate.html.