A similar issue has been posted in the past about scaffolding in .net core 2 but that was on a
date column and no solution has been posted to date.
There’s no specific table as any table containing a
datetime column type throws the following error from the console:
Could not find type mapping for column 'database.table.columnname' with data type 'datetime'. Skipping column.
This answer to a question about reading
datetime values and a MySQL quirk with
0000-00-00 00:00:00 values made me wonder if changing the connection string format would help. So I added the
ConvertZeroDateTime=true to the connection string in the scaffold command:
Scaffold-DbContext "server=localhost;port=3306;user=root;password=notherealpassword;database=sodb;ConvertZeroDateTime=true;" MySql.Data.EntityFrameworkCore -OutputDir Model -f
I still have the same error, does anyone have any suggestions? I have 380+ tables in this database so an automated solution would be most helpful.
I had the same problem and now I solved it.
I can’t be assured if my solution works to your case but I think this solution would work to your case.
- Remove all packages related to Entity Framework.
- Install the following packages the version is 5.0.4
- Open Package Manager Console window. Now we will install Pomelo packages it depends on .Net standard.
- Enter the command “Install-Package Pomelo.EntityFrameworkCore.MySql -Version 5.0.0-alpha.2”
- Enter the command “Install-Package Pomelo.EntityFrameworkCore.MySql.NetTopologySuite -Version 5.0.0-alpha.2”
The commands try to install the following packages.
Now Enter to Package Manager Console window the following command. Scaffold-DbContext “server=localhost;port=3306;uid=root;pwd=notherealpassword;database=sodb; “Pomelo.EntityFrameworkCore.MySql” -OutputDir Models -f
I hope this post helps you.