When I use Entity Framework as an ORM, for each Date
data type in my SQL Server DB it creates a DateTime
data type y
in my MVC project.
I mean, for each table in my DB, in my MVC project is auto-generated the code for this class using DateTime
data type, but I don't need time, only the date.
So my question is: what can I do to declare this field as Date
only data type or How is commonly handled this situation?.
public partial class Employee
{
public int Id_Employee { get; set; }
public string Name { get; set; }
public string Last_Name { get; set; }
public Nullable<System.DateTime> B_Date { get; set; }
public Nullable<int> SSN_L4 { get; set; }
public string Phone_N { get; set; }
public string Adress_L1 { get; set; }
public string Adress_City { get; set; }
}
Use the following
[Column(TypeName="Date")]
public DateTime ReportDate { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With