I need to work on ASP.NET MVC for a while. I am doing a tutorial Create a movie database in ASP.NET MVC that still uses the ADO.NET Enity Model. I managed to create a list view from the LINQ Entity Model. So here is my problem. The Bind attribute does not work on my SQL entity.
Original code with Ado.NET
public ActionResult Create([Bind(Exclude="Id")] Movie movieToCreate)
{
if (!ModelState.IsValid)
return View();
_db.AddToMovieSet(movieToCreate);
_db.SaveChanges();
return RedirectToAction("Index");
}
My LINQ Code
public ActionResult Create([Bind(Exclude = "Id")] Movies movieToCreate)
{
if (!ModelState.IsValid)
{
return View();
}
_db_linq.Movies.InsertOnSubmit(movieToCreate);
_db_linq.SubmitChanges();
return RedirectToAction("Index");
}
But the Id field is not excluded. Any ideas? Thanks!
source
share