ef核心到mysql表绑定

cnwbcb6i  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(258)

我在mysql中有下表

当我在一些中间件中运行以下代码时

var apiKeys = _appContext.apikey.ToList();

我得到这个错误
system.invalidoperationexception:类型“system.int16”和“system.boolean”之间未定义强制运算符。
这是我的apikey课程

public class ApiKey
{
    public string apikeyid { get; set; }
    public string uid { get; set; }
    public string apikey { get; set; }
    public bool isactive { get; set;}
    public bool ispaid { get; set; }
    public bool ismod { get; set; }
    public bool isadmin { get; set; }
}

我和一个postgresql数据库一起工作,刚刚转到mysql。这和从tinyint(在db里)到bool(在课堂上)有关系吗?
我在用 MySql.Data.EntityFrameworkCore 8.0.13

cczfrluj

cczfrluj1#

2个可能的选项,如已在评论中回答的。
pomelo驱动程序支持bool到intMap,
第二种选择是使用值转换器,它与另一个驱动程序一起工作。
entity.property(p=>p.isactive).hascoversion();

相关问题