mosh-hamedani / vidly-mvc-5

952 stars 1.52k forks source link

exceptionMessage": "Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.", "exceptionType": "System.Data.Entity.Validation.DbEntityValidationException #95

Open syedsaq opened 4 years ago

syedsaq commented 4 years ago

I got exception message, on birthdate,while i removed custom validation on date of birth i got exception like this in postman "message": "An error has occurred.", "exceptionMessage": "Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.", "exceptionType": "System.Data.Entity.Validation.DbEntityValidationException", "stackTrace": " at System.Data.Entity.Internal.InternalContext.SaveChanges()\r\n a

muresan87 commented 3 years ago
        if (!ModelState.IsValid)
        {
            var viewModel = new CustomerFormViewModel
            {
                Customers = customers,
                MembershipTypes = _context.MembershipTypes.ToList()
            };
            return View("CustomerForm",viewModel);
        }

Make sure you put ( ! ) before ( ModelState.IsValid ) .

TranHuy0711 commented 1 month ago

I have same question and I already have put (ModelState.IsValid) but still not work