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
Post a Comment