Scaffold a table with a string column e.g. varchar(128).
Scaffolding produces code:
entity.Property(e => e.Columnname)
.IsRequired()
.HasColumnName("columnname")
.HasColumnType("varchar(128)")
.HasCharSet("utf8mb4");
The HasCharSet() method has the following compilation error:
Argument type 'string' is not assignable to parameter type 'Pomelo.EntityFrameworkCore.MySql.Storage.Internal.CharSet'
MySQL version: 10.1.41-MariaDB-0ubuntu0.18.04.1
Operating system: Ubuntu 18.04
Pomelo.EntityFrameworkCore.MySql version: 3.0.0-rc2.final
Microsoft.AspNetCore.App version: 3.0
The following code should work around the issue:
c#
entity.Property(e => e.Columnname)
.HasCharSet(CharSet.Utf8Mb4);
I will check, why the scaffolder returns a string instead of a CharSet.Utf8Mb4.
Right, I guess I should note that it appears to return a string instead of a CharSet object for any character set type - not just uft8mb4.
Thanks!
Just an observation, but reading Column Character Set and Collation I wonder if would be preferable to omit HasCharSet() when the column charset matches the table.
@mguinness That is definitely something we should consider in the future. We would have to annotate the entity with the table's charset (like we do with properties and their columns now) to support that.
Please open an issue for that, so we don't forget it!
@Slushnas Thank you for reporting this issue! It is fixed with #914.