Page 1 of 1

"Specified cast is not valid" when using enum type as primary key

Posted: Tue 16 Aug 2022 00:56
by potato
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:
  1. 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;
  2. Create a new EF Core model using default settings (database first, adding TestTable to the model, etc)
  3. Add a new enum type using default settings
  4. Change the type of TestTable.Id to the new enum type
  5. Click Model->Update Model From Database
  6. Click next
"Specified cast is not valid."

Re: "Specified cast is not valid" when using enum type as primary key

Posted: Tue 04 Oct 2022 07:31
by Shalex
Thank you for your report. We have reproduced the issue and will notify you when it is fixed.