entity framework - C# try/catch not working as expected -


i working on console app daily imports our cms parent erp system. having funky issue try/catch blocks. errors happening inside try's , not making catch. @ first, did go catch , able figure out issue, it's erroring on try , staying there. hitting continue doesn't work, keeps showing error again , again. error has ef , 1 of models not having required field...

     public void save()     {         try         {             _context.savechanges(); <--bombs here , never lets me step thru         }         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;         }     } 

it throwing more or different exception. try using

catch (exception e) 

and see if enters catch , log exception know getting


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -