siva nathan

siva nathan

  • 862
  • 819
  • 217.4k

why we use this code in mvc entity framewirk

Jun 20 2017 12:05 PM
// GET: /Student/Create public ActionResult Create() { return View(); } // // POST: /Student/Create [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return RedirectToAction( "Index" ); } return View(student); } // what is meant by model state.isvalid why we check before to add student. and why we use save changes() method here?

Answers (2)