.Net Core 3.1 WebApi项目新账号请求用户登录接口(/User/Login)报错-已解决
报错内容
{ "Tag": 0, "Message": "An error occurred while updating the entries. See the inner exception for details.", "Description": null }
说明:在请求登录接口时,提示的报错信息;
报错原因
断点查找错误的精确原因:Data too long for column 'xxx' at row 1
对比项目代码区别
//.net core 2.2版本中的GetGuid方法: public static string GetGuid() { return Guid.NewGuid().ToString().Replace("-", string.Empty).ToLower(); }
//.net core 3.1版本中的GetGuid方法: public static string GetGuid(bool replaceDash = false) { string guid = Guid.NewGuid().ToString(); if (replaceDash) { guid = guid.Replace("-", string.Empty); } return guid; }
解决方式
获取guid的方法中,如果直接调用GetGuid()方法,得到的数据中包含‘-’。需要传入bool变量为true:GetGUID(true),来清除guid中的‘-’符号。
因为报错的精确原因是字段数据的长度超限。