I've been having som issues when saving POCO entities with a DateTime property. When the DateTime property has the value of DateTime.MinValue the SaveChanges() fails because of the difference between SqlDateTime.MinValue and DateTime.MinValue.
So, what to do?
1) Should I check for DateTime.MinValue before saving the entity?
2) Should I have my datetime POCO property designed something like this?
private SqlDateTime _created;
public virtual DateTime Created
{
get
{
return _created.Value;
}
set
{
_created = value == DateTime.MinValue ? SqlDateTime.MinValue : value;
}
}
/PW