I have a test class and an ExecutionDate
property which stores only date but when we use [DataType(DataType.Date)]
that also stores the time portion in database but I want only date portion.
public class Test
{
[Key]
public int Id { get; set; }
[DataType(DataType.Date)]
public DateTime ExecutionDate { get; set; }
}
Is any way to store only date on time portion in db using Entity Framework? Please help me....
I have added snapshot when use [DataType(DataType.Date)]
that stores time portion 00:00 I want remove that
DATETIME
- then of course you get date & time stored. The database column must be of datatypeDATE
- not just your attribute on the C# class! – CaulkDATE
! – CaulkDATE
on the database level - in .NET and Entity Framework, we don't have a specific "date-only" datatype. In .NET code, you always have date&time - can't change that. But in the SQL Server database table, you can make it aDATE
and store the date only – Caulk