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

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
potato
Posts: 1
Joined: Tue 16 Aug 2022 00:48

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

Post by potato » 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:
  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."

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Tue 04 Oct 2022 07:31

Thank you for your report. We have reproduced the issue and will notify you when it is fixed.

Post Reply