c# - Trying to catch DbEntityValidationException but skips straight to general exception -


note: ef6

i adding several dozen each of 3 or 4 different types of entities before calling savechanges. when do, im catching exception inner exception message indicates "string or binary data truncated". pretty obvious 1 of fields trying put string field of 1 of tables isnt large enough hold it. question - field. 1 of tables has 30-40 fields.

sometimes while debugging, if there fk constraint error, see entityvalidationerrors in locals window. in case not.

so trying catch ef errors identify culprit, in code below, skips straight catch on general exception.

        //were done         try         {             ctx.savechanges();         }          catch(dbentityvalidationexception ef)         {             retval = -1;             throw ef;         }         catch(exception ex)         {             retval = -1;             throw ex;         } 

how can identify field/entity causing issue?


Comments

Popular posts from this blog

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -