diff --git a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs index e5719e76e..1a4a8b04c 100644 --- a/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs +++ b/src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs @@ -785,7 +785,14 @@ static Type FindTypeToInstantiate(Type collectionType, Type elementType) EnumDefinition? enumDefinition; if (storeType is null) { - enumDefinition = _enumDefinitions.SingleOrDefault(m => m.ClrType == clrType); + var matches = _enumDefinitions.Where(m => m.ClrType == clrType).ToList(); + if (matches.Count > 1) + { + throw new InvalidOperationException( + $"Multiple enum definitions registered for CLR type '{clrType?.FullName}'. "); + } + + enumDefinition = matches.FirstOrDefault(); if (enumDefinition is null) {