Bug #102680 MySql.EntityFrameworkCore unable to map datetime columns
Submitted: 22 Feb 2021 3:09 Modified: 14 May 2021 16:23
Reporter: Michael Lowery Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.0-m8.0.23 OS:Windows (Visual Studio 2019 Enterprise)
Assigned to: CPU Architecture:Any (.NET 5.0)
Tags: MySQL, MySql.EntityFrameworkCore

[22 Feb 2021 3:09] Michael Lowery
Description:
After connecting to a MySQL database with tables containing datetime columns, running Scaffold-DbContext produces this error:

Could not find type mapping for column 'MyDB.MyTable.MyColumn' with data type 'datetime'. Skipping column.

This occurs for all tables/columns of type datetime.

How to repeat:
Create a MySQL DB containing tables with datetime columns.
Create a .NET 5.0 project in Visual Studio 2019.
Install NuGet packages MySql.EntityFrameworkCore & Microsoft.EntityFrameworkCore.Tools.

Scaffold the MySQL DB:
Scaffold-DbContext "Server=MyServer;Port=3306;Database=MyDB;Uid=MyID;Pwd=MyPw;" MySql.EntityFrameworkCore -OutputDir MyDBContext -f -Verbose

Observe above error.

Suggested fix:
Provide proper mapping of datetime columns to .NET DateTime type.
[22 Feb 2021 5:14] MySQL Verification Team
Hello Michael Lowery,

Thank you for the report and feedback.
Imho this is duplicate of Bug #102381, please see Bug #102381 - fixed as of the upcoming MySQL Connector/NET 8.0.24 release.

regards,
Umesh
[14 May 2021 14:40] edilson amaral
Bug still happening in 8.0.25

Could not find type mapping for column 'myfiled' with data type 'datetime'. Skipping column.

Could not find type mapping for column 'myfield2' with data type 'timestamp'. Skipping column.
[14 May 2021 16:23] Michael Lowery
Working for me with v5.0.3.