My save functionality is getting this exception, before all my form fields were saving to my table on DB.
-
-
- public ActionResult SubmitRegDetails(RegViewAndRoleViewModel eNtsaRegistration)
- {
-
-
- if(ModelState.IsValid)
- {
- eNtsaRegistration.RegForm.Id = Guid.NewGuid();
- db.eNtsaRegForms.Add(eNtsaRegistration.RegForm);
- db.SaveChanges(); // Throws error here each time want to save changes to DB.
- return RedirectToAction("SaveRegForm");
- }
-
-
- public class eNtsaRegForm
- {
- [Key]
- public Guid? Id { get; set; }
- public string Title { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public string Position { get; set; }
- public string Company { get; set; }
- public string StreetAddress { get; set; }
- public string StreetAddressLine { get; set; }
- public string City { get; set; }
- public string StateProvince { get; set; }
- public int ZipCode { get; set; }
- public string Country { get; set; }
-
- [Required(ErrorMessage = " This field is required")]
- [EmailAddress(ErrorMessage = "Invalid email address")]
- public string Email { get; set; }
-
- public int CellNumber { get; set; }
- public string DietaryRequirements { get; set; }
-
-
- }
