I'm trying to insert only Date and Card into my database table and I'm getting the below error
Error Exception {"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."}
Here is my table structure
Here is my class for TimeOutJustification
public class TimeoutJustification
{
public long ID { get; set; }
public DateTime Date { get; set; }
public string Card { get; set; }
public DateTime TimeIn { get; set; }
public DateTime TimeOut { get; set; }
public long TotalTime { get; set; }
[NotMapped]
public TimeSpan TotalTimeSpan
{
get
{
return new TimeSpan(TotalTime);
}
set
{
TotalTime = value.Ticks;
}
}
public string Justification { get; set; }
public string Details { get; set; }
public string GeneralJustification { get; set; }
}
}
An error exception 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." get caught whenever I'm saving into database.
Hence I'm using entity framework and my ID in my database is auto increment
Here is an example of how it looks like
List<TimeoutJustification>withOutTimeOuts;
withOutTimeOuts.Add(new TimeOutJustification{Card="1234",Date="12-03-19"}
db.JustificationTable.AddRange(withOutTimeOuts);
//Error Gets Caught here
db.SaveChanges();