I am trying to save Time with entity framework. I am not really bothered about the date. I have declared my property as DateTime in Code and I am using CodeFirst.
In the xaml I use xceed TimePicker to display the Time as below
<Xceed:TimePicker Grid.Row="6" Grid.Column="1" Margin="5" Value="{Binding SelectedItem.UpdateTimer, Mode=TwoWay}" Format="LongTime" />
The problem is that when I run my application for the first time, The Datetime received by my property in code is '01/0/1/0001' for date followed by the time I have entered. When I try to save my context, I get this error which probably means that SQL Server does not like my date. How should I fix this?
"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."
My Property code is
public DateTime UpdateTimer
{
get
{
return Data.UpdateTimer;
}
set
{
if (value != Data.UpdateTimer)
{
Data.UpdateTimer = value;
OnPropertyChanged("UpdateTimer");
}
}
}