带有Mysql的EF Core无法将BIT(1)设置为布尔值 [英] EF Core with Mysql not scaffolding BIT(1) to Boolean

查看:592
本文介绍了带有Mysql的EF Core无法将BIT(1)设置为布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过现有数据库(首先是数据库)生成数据库类。网络核心CLI。

I am trying to generate DB classes from the existing database (DB first) through. Net core CLI.

数据库可以完美地与EF5和.net4.5配合使用,但是在迁移到EF核心后,bit(1)字段不会像bool那样脚手架

The DB was perfectly working with EF5 and .net4.5 but after migrate to EF core the bit(1) field is not scaffolding as bool instead it is generating as short.

也尝试过TinyInt(1)但没有运气。

Also tried with TinyInt(1) but no luck.

技术堆栈-
.Net核心-2.2
MySql.Data.EntityFrameworkCore(8.0.15)
MySQl Connector Net 8.0.13
innodb_version 8.0.13

Technology Stack - .Net core - 2.2 MySql.Data.EntityFrameworkCore (8.0.15) MySQl Connector Net 8.0.13 innodb_version 8.0.13

推荐答案

首先,您需要从Nuget添加此软件包:

MySql.Data.EntityFrameworkCore

Microsoft.EntityFrameworkCore.Design


然后运行以下命令:

First you need to add this packages from Nuget:
MySql.Data.EntityFrameworkCore
Microsoft.EntityFrameworkCore.Design
then run this command :

Scaffold-DbContext "server=localhost;port=3306;user=root;password=mypass;database=sakila" MySql.Data.EntityFrameworkCore -OutputDir model -f

如果此解决方案仍无法正常工作,请尝试以下解决方案:
https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

if this solution still not working try this solution : https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

这篇关于带有Mysql的EF Core无法将BIT(1)设置为布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆