Trying to create a model edit. Error pops up:
Index.cshtml:
@{ ViewBag.Title = "Index"; Layout = "~/Views/_Layout.cshtml"; } @model justfortest.Models.Book @using (Html.BeginForm("Index", "Home", FormMethod.Post)) { <fieldset> @Html.HiddenFor(m => m.Id) <p> @Html.LabelFor(m => m.Name, "Название книги") <br /> @Html.EditorFor(m => m.Name) </p> <p> @Html.LabelFor(m => m.Author, "Автор") <br /> @Html.EditorFor(m => m.Author) </p> <p> @Html.LabelFor(m => m.Price, "Цена") <br /> @Html.EditorFor(m => m.Price) </p> <p><input type="submit" value="Отправить" /></p> </fieldset> } HomeController:
BookContext db = new BookContext(); [HttpGet] public ActionResult Index() { return View(db.Books); } [HttpPost] public ActionResult Index(Book book) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { db.Dispose(); base.Dispose(disposing); } There are models. DB tables are filled with data


