更新条目时发生错误。有关详细信息,请参阅InnerException。 [英] An error occurred while updating the entries. See the InnerException for details.
本文介绍了更新条目时发生错误。有关详细信息,请参阅InnerException。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
各位大家好,当我在第一个ASP.Net MVC应用程序中尝试更新数据库中的数据时出错,错误是
Hello everybody,I got an error when I was trying to updating the data in the database in my 1st ASP.Net MVC application and the error is "
An error occurred while updating the entries. See the InnerException for details.
所以请帮我解决一下我的问题。下面是代码:
So please help me to solve out my this problem.Here's below is the code:
public ActionResult Create()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create([Bind(Exclude="Id")] Movie movieToCreate)
{
if (!ModelState.IsValid)
return View();
_db.AddToMovies(movieToCreate);
_db.SaveChanges(); //Error Line
return RedirectToAction(movieToCreate);
}
推荐答案
如果您在Movie类中有任何DateTime属性,请使用当前的DateTime初始化,如下所示保存
If you have any DateTime property in Movie class please initialize with current DateTime like below before save
movieToCreate.DateProperty=DateTime.Now;
_db.AddToMovies(movieToCreate);
_db.SaveChanges();
希望这有帮助
Hope this helps
这篇关于更新条目时发生错误。有关详细信息,请参阅InnerException。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文