I am using Entity Framework Code First method to create my database table. The following code
creates a DATETIME
column in the database, but I want to create a DATE
column.
[DataType(DataType.Date)]
[DisplayFormatAttribute(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public DateTime ReportDate { get; set; }
How can I create a column of type DATE
, during table creation?
Try to use ColumnAttribute
from System.ComponentModel.DataAnnotations
(defined in EntityFramework.dll):
[Column(TypeName="Date")]
public DateTime ReportDate { get; set; }