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"

this image of createuser action

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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -