asp.net - I am trying to create a User , all is working , object is getting the data but obj.saveChanges() is not working -
following exception occuring while saving changes
"an exception of type 'system.data.entity.validation.dbentityvalidationexception' occurred in entityframework.dll not handled in user code"
actually should see errors if drill array in visual studio during debug. can catch exception , write out errors logging store or console.
here sample code check field has not been validated.
try { // code... context.savechanges(); } catch (dbentityvalidationexception e) { foreach (var eve in e.entityvalidationerrors) { console.writeline("entity of type \"{0}\" in state \"{1}\" has following validation errors:", eve.entry.entity.gettype().name, eve.entry.state); foreach (var ve in eve.validationerrors) { console.writeline("- property: \"{0}\", error: \"{1}\"", ve.propertyname, ve.errormessage); } } throw; }
entityvalidationerrors
collection represents entities couldn't validated successfully, , inner collection validationerrors
per entity list of errors on property level.
these validation messages helpful enough find source of problem.
Comments
Post a Comment