EF Core with Mysql not scaffolding BIT(1) to Boole

2019-07-30 14:58发布

问题:

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

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.

Also tried with TinyInt(1) but no luck.

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

回答1:

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

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