Bug #94687 EF Core 2.2 BIT(1) converting as short instead of bool
Submitted: 18 Mar 2019 7:45 Modified: 5 May 2020 22:30
Reporter: Nitin Sharma Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Visual Studio Integration Severity:S2 (Serious)
Version:MySql.Data.EntityFrameworkCore (8.0.15) OS:Windows
Assigned to: CPU Architecture:Any
Tags: Connector (8.0.13), dotnet core, MySql.Data.EntityFrameworkCore (8.0.15)

[18 Mar 2019 7:45] Nitin Sharma
Description:
I am trying to generate db class from the existing database (DB first) through dotnet core CLI.

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

Dotnet core - 2.2
MySql.Data.EntityFrameworkCore (8.0.15)
MySQl Connector Net 8.0.13

How to repeat:

Run following CLI command on VS console - 

dotnet ef dbcontext scaffold "server=localhost;port=3306;user=root;password=pass123;database=ws" MySql.Data.EntityFrameworkCore -c DataContext -o 'DataModel' -p Model -s Model --use-database-names -f

and after it is generating BIT(1) AS short filed 

"public short is_weight_wise { get; set; }"

I also tried with TinyInt(1) but no luck.
[20 Dec 2019 15:54] MySQL Verification Team
Thank you for the bug report. Please provide the complete test case application file.
[21 Jan 2020 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[2 May 2020 15:36] Diego Toro
Enviroment:
MySql engine: 8.0.17
.Net Core:  3.1.3
EF Core: 3.1.3
MySql Connector: 8.0.20

creation database:
CREATE DATABASE ef_core_test
	CHARACTER SET utf8mb4
	COLLATE utf8mb4_0900_ai_ci;

Creation table for testing:
CREATE TABLE test_type_table (
  id INT(11) NOT NULL AUTO_INCREMENT,
  bit_type BIT(1) DEFAULT b'1',
  tinyint_type TINYINT(1) DEFAULT 1,
  varchar_type VARCHAR(255) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_0900_ai_ci;

scaffolding command:
dotnet ef dbcontext scaffold "server=localhost;port=3306;user=root;password=Abc123;database=ef_core_test;TreatTinyAsBoolean=true" MySql.Data.EntityFrameworkCore -o ef_core_test -f

C# class genetared
public partial class TestTypeTable
    {
        public int Id { get; set; }
        public short? BitType { get; set; }
        public byte? TinyintType { get; set; }
        public string VarcharType { get; set; }
    }
	
Expeted result:
public partial class TestTypeTable
    {
        public int Id { get; set; }
        public bool? BitType { get; set; }
        public bool? TinyintType { get; set; }
        public string VarcharType { get; set; }
    }
[5 May 2020 22:30] MySQL Verification Team
Duplicate of https://bugs.mysql.com/bug.php?id=99419.