How to identify the Entity that throws the error when saving?

Asked

Viewed 69 times

3

In my application, with Entity Framework, I make a query in a Round entity:

var lista = contexto.Rodada.Where(condições);

Then I’ll go over that list with a foreach.

During iteration "updates" and "Inserts" occur from multiple entities and one of them is responsible for the following 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.

Searching, I saw that the reason for this error is that the default (or minimum) value for datetime in c# is outside the range of values accepted in Sql Server:

see link

I’m trying to pinpoint where this happens, but there’s a lot of datetimes across multiple entities, and the stack trace didn’t help me at all. Is there any way to identify the entity that launched the error?

  • Put all the code in your question, please, to identify the problem? Which version of the Sqlserver database also

1 answer

1

  • 1

    Thanks @Gypsy! I found that they touched the bank and added a new date column. It assigns the value and works again. But I will force the error and test your solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.