简体   繁体   中英

Entity framework problem: How to handle errored column

I'm using ado.net entity data model. When update entity object, this error shown "String or binary data would be truncated" or "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM." . I know why this error shown.

How to handle this error created on which column ?

You probably have an uninitialized DateTime property on your object. The default value, which is in the year 0, cannot be stored in SQL Server's weirdly limited DATETIME columns. Set the property to a reasonable value or make it nullable in your DB.

In addition to Craig you could set both - the db-field and the variable - to nullable. Might be a bit more performant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM