We are migrating from the Pomelo to the Microting provider. Leveraging the native JSON support introduced in recent EF Core versions, we want to move some configurations from custom ValueConverters/validators to direct EF Core management
For example configuration for Roles (string[]) from:
builder.Property(cce => cce.Roles)
.HasColumnName("Roles")
.HasColumnType("json")
.HasConversion(
v => JsonSerializer.Serialize(v, _jsonSerializerOptions),
v => JsonSerializer.Deserialize<string[]>(v, _jsonSerializerOptions)
);
become simply:
builder.Property(cce => cce.Roles)
.HasColumnName("Roles");
While this simplifies our codebase significantly, it introduces a consistency gap: the database lacks a native constraint to validate the JSON format (e.g., json_valid(Roles)). Consequently, while the mapping works perfectly, we currently need to add these validation checks manually at the DB level.
Any advice?
So thanks.
Diego
We are migrating from the Pomelo to the Microting provider. Leveraging the native JSON support introduced in recent EF Core versions, we want to move some configurations from custom ValueConverters/validators to direct EF Core management
For example configuration for Roles (string[]) from:
become simply:
While this simplifies our codebase significantly, it introduces a consistency gap: the database lacks a native constraint to validate the JSON format (e.g., json_valid(Roles)). Consequently, while the mapping works perfectly, we currently need to add these validation checks manually at the DB level.
Any advice?
So thanks.
Diego