public ActionResult OnPost() { var patient = Patient; if (!ModelState.IsValid) //validate the dataanotations defined for the model { return(Page()); // return page } PatientClient pc = new PatientClient(); pc.Create(patient); // var result = _Context.Add(patient); //_Context.SaveChanges(); // Saving Data in database return(RedirectToPage("AllPatient")); }