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.
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
The result of command is as below.
I hope this post helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With