"Specified cast is not valid" when using enum type as primary key
Posted: Tue 16 Aug 2022 00:56
Setting the type of a table's primary key to an enum type causes "Update Model From Database" to fail with the error "Specified cast is not valid".
Reproduction with Entity Developer 7:
Reproduction with Entity Developer 7:
- Create the following MySQL table:
Code: Select all
CREATE TABLE `TestTable` ( `Id` INT(10) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`Id`) USING BTREE ) COLLATE='utf8mb4_unicode_ci' ENGINE=InnoDB;
- Create a new EF Core model using default settings (database first, adding TestTable to the model, etc)
- Add a new enum type using default settings
- Change the type of TestTable.Id to the new enum type
- Click Model->Update Model From Database
- Click next