我将 ASP.NET CORE 2 与 MySQL 5.6.27、Dapper 1.50.2 和 Dapper.Contrib 1.50.0 一起使用。尝试使用模型执行基本插入操作时出现错误,但是如果我使用普通的 INSERT INTO SQL 查询,则操作成功。
这是我得到的错误:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'WHERE 1 = 0)、(SELECT NULL WHERE 1 = 0)、(SELECT NULL WHERE 1 = 0)、(SELECT NULL' 附近使用正确的语法
代码:
using (IDbConnection dbConnection = Connection)
{
dbConnection.Open();
var newUser = dbConnection.Insert(entity); // error on this line
}
模型类
public partial class Aspnetusers
{
[Key]
public int Id { get; set; }
public string UserName { get; set; }
public int AccessFailedCount { get; set; } = 0;
public string Email { get; set; }
public bool EmailConfirmed { get; set; } = false;
public bool IsActive { get; set; } = true;
public bool IsRootUser { get; set; } = false;
public bool LockoutEnabled { get; set; } = false;
public string PasswordHash { get; set; }
public bool PhoneNumberConfirmed { get; set; } = false;
public bool TwoFactorEnabled { get; set; } = false;
}
我尝试将 Dapper 和 Dapper.Contrib 更新到 1.50.5,但仍然是同样的错误。
请在这里提出不正确的建议。
问候, 雅利安