Question: How do you resolve the error: SqlException: The conversion of a datetime2 data type to a DateTime data type resulted in an out-of-range value. The statement has been terminated
Please Login to see the rest of the answer
Answer: Take a look in your Database table, chances are that you have created a DateTime column in your Database table and made it nullable at the same time, you added a default-binding of getdate() to populate the column with default date.
However in your application code, you are not defining what that DateTime should be in the Database Table column, since you made the DateTime nullable in the database, it is expecting the DateTime to be populated by application code. You should explicitly pass in the DateTime in your data modal class or make the column field not nullable in your database table while you allow default-binding of getdate().
Call to Action: Sign up for a free account so to be notified when a new solution is found.
SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. My answer is: The date passed into the Controller is most likely null or is set to default. Make sure you set the date in your Controller when the payload has been received.
If you still have an error, make sure you create a handling object e.g. MyPocal pocal = _callYourService.Function this way you the result from the _callYourService.Function is kept in pocal object. This is the work around this problem.