[HttpPost]
public ActionResult Create(FormCollection collection)
{
UpdateModel(collection);
context.SaveChanges();
return RedirectToAction("Index", new {controller = "Home"});
}
操作成功,但沒有重新插入到數據庫中。爲什麼?ASP.NET MVC:POST後沒有添加到數據庫的記錄
我不想通過從表單集合中的每個字段獲取每個值來手動創建一個對象。
您必須插入模式,而不是對其進行更新。您應該通過另一個存儲庫功能插入它。 – 2011-01-22 22:11:15
謝謝Ufuk人。 – user469652 2011-01-22 22:12:45