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
This is just an enhancement for the most up-voted answer by @LadislavMrnka on this question
if you have a lot of Date columns, then you can create custom attribute and then use it when ever you want, this will produce more clean code in the Entity classes
public class DateColumnAttribute : ColumnAttribute
{
public DateColumnAttribute()
{
TypeName = "date";
}
}
Usage
[DateColumn]
public DateTime DateProperty { get; set; }