Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Applying validation for a postcode field which is a requried but while editing iam not using postcode in my form even iam not using it iam getting error '
C#
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details

'

C#
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
           {
               Exception raise = dbEx;
               foreach (var validationErrors in dbEx.EntityValidationErrors)
               {
                   foreach (var validationError in validationErrors.ValidationErrors)
                   {
                       string message = string.Format("{0}:{1}",
                           validationErrors.Entry.Entity.ToString(),
                           validationError.ErrorMessage);
                       // raise a new exception nesting
                       // the current instance as InnerException
                       raise = new InvalidOperationException(message, raise);
                   }
               }
               throw raise;
           }

by using above code iam able to trace my what is exact error. is showing enter postcode which was not present in my form. (postcode is in my model class which is requried)
plz Help me out??
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900