Is there an existing issue for this?
Description
Description
When creating a new ABP 10.4.0 monolith application with MySQL default configuration, running the initial EF Core migration fails with the following error:
MySqlConnector.MySqlException: Specified key was too long; max key length is 3072 bytes
This issue blocks all new ABP MySQL projects from running initial migrations by default.
ABP Version
10.4.0
Database Provider
MySQL 8.0+ (InnoDB)
Problem Details
The migration fails when creating the unique index on the AbpResourcePermissionGrants table:
CREATE UNIQUE INDEX `IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_ResourceKey_ProviderName_ProviderKey`
ON `AbpResourcePermissionGrants` (
`TenantId`,
`Name`,
`ResourceName`,
`ResourceKey`,
`ProviderName`,
`ProviderKey`
);
This is a 6-column composite unique index
With ABP's default utf8mb43072 bytes
Reproduction Steps
-
Create a new ABP 10.4.0 monolith solution:
abp new MonoOnAbp -u angular -dbms MySQL -m none --theme leptonx-lite -csf -scp --connection-string "Server=localhost;Port=3306;Database=MonoOnAbp;Uid=root;Pwd=123456;"
-
Set up a valid MySQL connection string
-
Run:
dotnet ef migrations add Initial
dotnet ef database update
-
Migration fails immediately.
Workaround / Fix I Used
I fixed it by reducing the max length of 3 long string fields in OnModelCreating in MonoOnAbpDbContext.cs:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigurePermissionManagement();
// FIX: MySQL index too long issue
builder.Entity<ResourcePermissionGrant>(e =>
{
e.Property(x => x.Name).HasMaxLength(128);
e.Property(x => x.ResourceName).HasMaxLength(128);
e.Property(x => x.ResourceKey).HasMaxLength(128);
});
}
This reduces index size so it fits within the 3072 bytes limit under utf8mb4.
Sample Repository
I have published a complete minimal reproduction repo here:
https://github.com/Keay5/abp-monolith-sample
Expected Behavior
ABP 10.4.0 should generate MySQL-compatible indexes by default.
Actual Behavior
All new MySQL projects fail on first run.
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
10.4.0
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
Is there an existing issue for this?
Description
Description
When creating a new ABP 10.4.0 monolith application with MySQL default configuration, running the initial EF Core migration fails with the following error:
This issue blocks all new ABP MySQL projects from running initial migrations by default.
ABP Version
10.4.0
Database Provider
MySQL 8.0+ (InnoDB)
Problem Details
The migration fails when creating the unique index on the
AbpResourcePermissionGrantstable:This is a 6-column composite unique index
With ABP's default
utf8mb43072 bytesReproduction Steps
Create a new ABP 10.4.0 monolith solution:
Set up a valid MySQL connection string
Run:
Migration fails immediately.
Workaround / Fix I Used
I fixed it by reducing the max length of 3 long string fields in
OnModelCreatinginMonoOnAbpDbContext.cs:This reduces index size so it fits within the 3072 bytes limit under
utf8mb4.Sample Repository
I have published a complete minimal reproduction repo here:
https://github.com/Keay5/abp-monolith-sample
Expected Behavior
ABP 10.4.0 should generate MySQL-compatible indexes by default.
Actual Behavior
All new MySQL projects fail on first run.
Reproduction Steps
No response
Expected behavior
No response
Actual behavior
No response
Regression?
No response
Known Workarounds
No response
Version
10.4.0
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response