why we use this code in mvc entity framewirk
// 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?