I am following this tutorial on how to create a simple database web application with ASP.NET MVC. I am having a problem with the 2nd Create
controller method in the home controller (in Listing 4). Specifically, the error - when the web app is built - is with the AddToMovieSet
method that actually saves the entries to the database.
It is worth noting that I am using VS 2016, whereas the tutorial uses a much older version (2008); this might be the reason to the problem. But, nevertheless, what is the code for this Create
controller method?
This is the code in the Create
action method in the home controller:
public ActionResult Create(Movie movieToCreate)
{
if (!ModelState.IsValid)
return View();
_db.AddToMovieSet(movieToCreate);
_db.SaveChanges();
return RedirectToAction("Index");
}