I am getting the error like above tag which will be at the place of
return View(st.employees.Find(id));
above place only ,can any one help me from this! and my code is
namespace StartApp.Controllers { public class EmployController : Controller { StartEntities st = new StartEntities(); //List public ActionResult List() { return View(st.employees.ToList()); } //Details public ActionResult Details(int id = 0) { return View(st.employees.Find(id)); } //Create public ActionResult Create() { return View(); } [HttpPost,ValidateAntiForgeryToken] public ActionResult Create(employee e) { using(st) { st.employees.Add(e); try { st.SaveChanges(); } catch { System.Diagnostics.Debug.WriteLine("Here is an error"); } } return RedirectToAction("List"); } //edit public ActionResult Edit(int id = 0) { return View(st.employees.Find(id)); } [HttpPost,ValidateAntiForgeryToken] public ActionResult Edit(employee e) { st.Entry(e).State = EntityState.Modified; st.SaveChanges(); return RedirectToAction("List"); } //Delete public ActionResult Delete(int id = 0) { return View(st.employees.Find(id)); } [HttpPost,ActionName("Delete")] public ActionResult Delete_conf(int id) { employee emp = st.employees.Find(id); st.employees.Remove(emp); st.SaveChanges(); return RedirectToAction("List"); } }
}
can any one help me to rectify that error!