I've just deployed server code that used to work literally a week ago. The part of the code that results in the error did not change, however the object itself did.
It is a Model First approach (converted from Database First), and I've added two association fields and two new tables to the model.
The part of the code that throws the error is mission critical. It basically disables concurrent editing of the value by setting a timestamp. However for some reason it does not work.
The particular code:
user.AlertConcurrency = DateTime.UtcNow;
db.SaveChanges();
The error:
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.
Now, the user.AlertConcurrency field is a datetime type in the database. I don't see why it even tries to do datetime to datetime2 conversion here. What am I missing?