You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure wether I'm doing something wrong or this functionality is a bit broken, but I'm setting up my enums like this:
vardataSourceBuilder=newNpgsqlDataSourceBuilder(configuration.ConnectionString);dataSourceBuilder.EnableDynamicJson();vardataSource=dataSourceBuilder.Build();services.AddDbContext<DCMContext>(options =>options.UseNpgsql(dataSource,
o =>{o.MapEnum<DeviceType>();o.MapEnum<DispatchStatus>();o.MapEnum<DriverStatus>();o.MapEnum<FuelType>();o.MapEnum<PaymentStatus>();o.MapEnum<PaymentType>();o.MapEnum<RateType>();o.MapEnum<SettingRight>();o.MapEnum<SettingType>();o.MapEnum<Sex>();o.MapEnum<TransferStatus>();o.MapEnum<TripCancelReason>();o.MapEnum<TripScope>();o.MapEnum<TripStatus>();}));
Now I'm getting this exception when retrieving data from the database:
System.InvalidCastException: Reading as 'DCM.Entities.Enums.Sex' is not supported for fields having DataTypeName 'public.sex'
---> System.NotSupportedException: Reading and writing unmapped enums requires an explicit opt-in; call 'EnableUnmappedTypes' on 'NpgsqlDataSourceBuilder' or NpgsqlConnection.GlobalTypeMapper....
And this is how the enum looks like:
publicenumSex{Unknown,Male,Female,Other}
As you can see the order is different, but I thought by reading through issue #3390 that it shouldn't matter. But still I'm getting above mentioned exception. Could somebody help me out?
Thank you
The text was updated successfully, but these errors were encountered:
I all,
I'm not sure wether I'm doing something wrong or this functionality is a bit broken, but I'm setting up my enums like this:
And create a migration which results in this:
And the model snapshot:
Now I'm getting this exception when retrieving data from the database:
And this is how the enum looks like:
As you can see the order is different, but I thought by reading through issue #3390 that it shouldn't matter. But still I'm getting above mentioned exception. Could somebody help me out?
Thank you
The text was updated successfully, but these errors were encountered: