microsoft sql server has time format for database column.
But how to configure it in entity framework code first?
I found DateTime but not Time
Refer to this link: http://msdn.microsoft.com/en-us/library/bb677243.aspx
microsoft sql server has time format for database column.
But how to configure it in entity framework code first?
I found DateTime but not Time
Refer to this link: http://msdn.microsoft.com/en-us/library/bb677243.aspx
hi i solved this problem in this way
i add my time property to my class as date time type and add one migrations
that migration is like this
CreateTable(
"dbo.Events",
c => new
{
Id = c.Int(nullable: false, identity: true),
EventName = c.String(nullable: false),
StartDate = c.DateTime(nullable: false, storeType: "date"),
EndDate = c.DateTime(nullable: false, storeType: "date"),
StartTime = c.Time(nullable: false),
EndTime = c.Time(nullable: false),
Description = c.String(),
})
.PrimaryKey(t => t.Id);
and after this i changed StartTime and EndTime type from Date time to time then you can run update-database command.
Use the DateTime datatype but ignore the Date and only view only the Time as desired. You could also use TimeSpans but I would say that the former option is still the easiest.
DateTime.Now.ToString("t");