【发布时间】:2018-05-17 07:48:09
【问题描述】:
我正在尝试让我的 JqGrid 更新我的数据库。我不断收到错误消息:“一个或多个实体的验证失败。有关详细信息,请参阅 'EntityValidationErrors' 属性。”
如何找出我的实际错误或导致错误的原因?
// TODO:insert a new row to the grid logic here
[HttpPost]
public string Create([Bind(Exclude = "Id")] AspNetUser obj)
{
//System.Diagnostics.Debug.WriteLine("Create");
string msg;
try
{
if (ModelState.IsValid)
{
db.AspNetUsers.Add(obj);
//db.AspNetUsers.Add(new AspNetUser { UserName = obj.UserName, Email = obj.Email });
db.SaveChanges();
msg = "Saved Successfully";
}
else
{
msg = "Validation data not successfull";
}
}
catch (Exception ex)
{
msg = "Error occured:" + ex.Message;
}
return msg;
}
【问题讨论】:
-
它已经在告诉你该怎么做 - 有关更多详细信息,请参阅 'EntityValidationErrors' 属性。"
-
另外,如果 EntityValiationErrors 不在异常
ex中,请尝试在内部异常中查找。 -
@stephenMuecke 我在哪里可以找到这个属性?
-
@codingYoshi 原谅我的无知,但我该怎么做呢?
-
转到 YouTube 并输入 debugging unhandled exception with Visual Studio
标签: c# asp.net-mvc jqgrid