Skip to content

Broken migrations when using MapEnum #3324

@meenzen

Description

@meenzen

Broken migrations when using MapEnum

When adding an enum like .MapEnum<MarriageStatus>("marriage_status") and generating a migration, that migration will fail:

Unhandled exception. Npgsql.PostgresException (0x80004005): 42710: type "marriage_status" already exists

I don't understand why this happens, but it seems that the enum is being created in the database before the migration is executed. Then the migration tries to create that same enum again so it fails.

As a workaround I've manually added

migrationBuilder.Sql("DROP TYPE IF EXISTS marriage_status;");

before the rest of the migration.

Reproduction

Reproduced using Npgsql.EntityFrameworkCore.PostgreSQL version 9.0.0-rc.2
https://github.com/meenzen/PostgresEnumError

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions