diff --git a/src/EFCore.PG/Infrastructure/Internal/EnumDefinition.cs b/src/EFCore.PG/Infrastructure/Internal/EnumDefinition.cs index b34be200e..b02ad9b78 100644 --- a/src/EFCore.PG/Infrastructure/Internal/EnumDefinition.cs +++ b/src/EFCore.PG/Infrastructure/Internal/EnumDefinition.cs @@ -71,7 +71,7 @@ public sealed class EnumDefinition : IEquatable /// public EnumDefinition( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] Type clrType, - string name, + string? name, string? schema, INpgsqlNameTranslator nameTranslator) { @@ -80,7 +80,7 @@ public EnumDefinition( throw new ArgumentException($"Enum type mappings require a CLR enum. {clrType.FullName} is not an enum."); } - StoreTypeName = name; + StoreTypeName = name ?? nameTranslator.TranslateTypeName(clrType.Name); StoreTypeSchema = schema; ClrType = clrType; diff --git a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs index e4abca786..7dba76190 100644 --- a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs +++ b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs @@ -214,7 +214,7 @@ public virtual NpgsqlOptionsExtension WithUserRangeDefinition( /// public virtual NpgsqlOptionsExtension WithEnumMapping( Type clrType, - string enumName, + string? enumName, string? schemaName, INpgsqlNameTranslator? nameTranslator) { diff --git a/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs b/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs index 12b3fc599..ad07f951d 100644 --- a/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs +++ b/src/EFCore.PG/Infrastructure/NpgsqlDbContextOptionsBuilder.cs @@ -121,7 +121,7 @@ public virtual NpgsqlDbContextOptionsBuilder MapRange( /// The name of the PostgreSQL schema in which the range is defined. /// The name translator used to map enum value names to PostgreSQL enum values. public virtual NpgsqlDbContextOptionsBuilder MapEnum( - string enumName, + string? enumName = null, string? schemaName = null, INpgsqlNameTranslator? nameTranslator = null) where T : struct, Enum @@ -136,7 +136,7 @@ public virtual NpgsqlDbContextOptionsBuilder MapEnum( /// The name translator used to map enum value names to PostgreSQL enum values. public virtual NpgsqlDbContextOptionsBuilder MapEnum( Type clrType, - string enumName, + string? enumName = null, string? schemaName = null, INpgsqlNameTranslator? nameTranslator = null) => WithOption(e => e.WithEnumMapping(clrType, enumName, schemaName, nameTranslator));