Class NpgsqlJsonElementHackConvention
- Assembly
- Npgsql.EntityFrameworkCore.PostgreSQL.dll
This convention is a hack around https://github.com/dotnet/efcore/issues/32192. To support the EF owned entity JSON support, EF requires that a lookup of the CLR type JsonElement return the provider's special JsonTypeMapping. But Npgsql has its own JSON DOM support, where actually mapping JsonElement is allowed as a weakly-typed mapping strategy. The two JSON type mappings are incompatible notably because EF's JsonTypeMapping is expected to return UTF8 byte data which is then parsed via Utf8JsonWriter (and not a string). So for properties actually typed as JsonElement, we hack here and set the type mapping rather than going through the regular type mapping process.
public class NpgsqlJsonElementHackConvention : IPropertyAddedConvention, IConvention
- Inheritance
-
NpgsqlJsonElementHackConvention
- Implements
- Inherited Members
Methods
ProcessPropertyAdded(IConventionPropertyBuilder, IConventionContext<IConventionPropertyBuilder>)
Called after a property is added to the entity type.
public void ProcessPropertyAdded(IConventionPropertyBuilder propertyBuilder, IConventionContext<IConventionPropertyBuilder> context)
Parameters
propertyBuilder
IConventionPropertyBuilderThe builder for the property.
context
IConventionContext<IConventionPropertyBuilder>Additional information associated with convention execution.