I am using AspNetCore.Identity.EntityFrameworkCore
(1.1.1) and SapientGuardian
(7.1.23) to generate a code first database, because I have a MySql database (MariaDB). When using the Updata-Database
command or context.Database.EnsureCreated();
the following exception is thrown:
Index column size too large. The maximum column size is 767 bytes.
I inspected some logs and found out that all tables are created. But while executing the Create Index [...]
queries the problem occurs. The following query is the last one before the exception is thrown:
CREATE INDEX EmailIndex ON AspNetUsers (NormalizedEmail);
The type of the Email
and NormalizedEmail
column is varchar(255)
What is the cause for this problem and how can I fix it?
Edit:
SELECT character_set_name, column_type FROM information_schema.`COLUMNS`
WHERE table_schema = "schema"
AND table_name = "AspNetUsers"
AND (column_name = "Email" OR COLUMN_NAME="NormalizedEmail");
Delivered:
|---------------------|------------------|
| character_set_name | column_type |
|---------------------|------------------|
| utf8 | varchar(256) |
|---------------------|------------------|
| utf8 | varchar(256) |
|---------------------|------------------|
Edit2: Manually adjusting the migrations generated by ef core solves this problem. I changed the max length attribute for all indices from 256 to 255. But is there a way to configure entity framework core to adjust the migrations?