Describe the bug
When configuring the DbContext to use "utf8mb4" as the character set and "utf8mb4_unicode_ci" as the collation, the first migration generated in an EF Core project does not include the specified collation. As a result, the created database uses an unexpected collation.
Configuration in DbContext:
builder.UseCollation("utf8mb4_unicode_ci");
builder.HasCharSet("utf8mb4", DelegationModes.ApplyToDatabases);
Generated Migration
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
I was expecting the following:
migrationBuilder.AlterDatabase(
collation: "utf8mb4_unicode_ci")
.Annotation("MySql:CharSet", "utf8mb4");
Is this behaviour expected?
To Reproduce
- Add following configuration to DbContext: (OnModelCreating)
builder.UseCollation("utf8mb4_unicode_ci");
builder.HasCharSet("utf8mb4", DelegationModes.ApplyToDatabases);
- Create a new EF Core project without migrations.
- Add the first migration.
The generated migration does not include the configured collation.
Expected behavior
When a collation is explicitly configured, it should be included in the generated migration.
Technical details (please complete the following information):
- Database server version: [MariaDB 11.4.9]
- Operating system: [Windows 11]
- Pomelo.EntityFrameworkCore.MySql version: [9.0.0.efcore.9.0.0]
- Other technical details: [ASP.NET Core]
Describe the bug
When configuring the DbContext to use "utf8mb4" as the character set and "utf8mb4_unicode_ci" as the collation, the first migration generated in an EF Core project does not include the specified collation. As a result, the created database uses an unexpected collation.
Configuration in DbContext:
Generated Migration
I was expecting the following:
Is this behaviour expected?
To Reproduce
The generated migration does not include the configured collation.
Expected behavior
When a collation is explicitly configured, it should be included in the generated migration.
Technical details (please complete the following information):