Error: Validation failed for one or more entities (C# MVC)

Error: Validation failed for one or more entities (C# MVC)

我正在尝试让我的 JqGrid 更新我的数据库。我不断收到错误消息:"Validation failed for one or more entities. See 'EntityValidationErrors' property for more details."

如何找出我的实际错误是什么或导致错误的原因?

 // 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;
    }

通常此异常表示数据库验证失败。如果您在数据库中有一个设置了字符数的字段,并且您试图向该字段保存一个超过数据库数的字符串,就会发生这种情况。

例如,使用 'varchar(max)' 更新您的数据库字符串类型。

希望对您有所帮助