Non-English characters become question marks when inserting into MySQL server in Ubuntu Linux server

This is because when the query is sent to MySQL, it’s encoded using the default charset, which is usually set to latin.

For some reason, it’s not a problem in Windows.

For PHP, when creating a connection to MySQL, call set_charset to set the character set to UTF8.

For ASP.NET Core application, set the charset in the connection string: CharSet=utf8.

EF Core Update-Database failed with MySQL

When trying to use the code first approach of Entity Framework Core to generate database and tables using MySQL. When running Update-Database in the package console manager, it shows an error saying table __efmigrationhistory doesn’t exists.

After digging in Stackoverflow, it seems that it’s a bug with the official MySQL connector. And at the time of this writing with this version 8.0.20 and .NET Core 3.1, this bug hasn’t been fixed. The connector is supposed to create this table for migration.

https://stackoverflow.com/a/46090571/9191495

In order to solve this problem there are two solutions

-Don’t use the official connector, use Pomelo.EntityFramework.MySql

https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql

-Alternatively create, the table yourself

CREATE TABLE `__EFMigrationsHistory` 
( 
    `MigrationId` nvarchar(150) NOT NULL, 
    `ProductVersion` nvarchar(32) NOT NULL, 
     PRIMARY KEY (`MigrationId`) 
);

It’s a waste of time, but what can one do.