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
{{ message }}
Repository navigation
Switch to storing enums as ints in JSON instead of strings #31100
We currently serialize .NET enums into JSON as their string label; this is:
Incompatible with the behavior of System.Text.Json and Newtonsoft.Json, which serialize to the underlying int value.
Incompatible with our relational behavior, which also value-converts to the int value. This notably means that it's impossible to compare an enum value inside JSON with another enum value outside of JSON in a LINQ query.
Reacted by Maurycy Markowski, Arthur Vickers and Peter Sladek
changed the title [-]Switch to storing enums as ints in JSON instead of ints[/-][+]Switch to storing enums as ints in JSON instead of strings[/+]on Jun 19, 2023
We ran into this issue - we have json stored in db with enum values as ints. Is there any workaround right now? i.e. possibility of specifying value converter for json property?
Activity
[-]Switch to storing enums as ints in JSON instead of ints[/-][+]Switch to storing enums as ints in JSON instead of strings[/+]petersladek commentedon Jun 28, 2023
We ran into this issue - we have json stored in db with enum values as ints. Is there any workaround right now? i.e. possibility of specifying value converter for json property?
ajcvickers commentedon Jul 5, 2023
@petersladek Use
HasConversion<int>on the property configuration insideOnModelCreating.`Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…
Fix to #31100 - Switch to storing enums as ints in JSON instead of st…