JsonPolymorphic support
onionhammer opened this issue · comments
Normal serialization/deserialization works with jsonpolymorphic, but as soon as it's saved up to the database, the property order is not preserved, and deserialization fails back from the database.
Using: .NET 8, EF Core 8, Npgsql
Using HasColumnType("jsonb")
since mapping arrays is not supported with ToJson()
When using HasColumnType("jsonb")
, EF isn't responsible in any way for how JSON gets serialized - that's delegated to System.Text.Json. In any case, the property order not being preserved is the document, by-design PostgreSQL behavior for jsonb
(property order in JSON is generally not meaningful). Specifically for polymorphic deserialization support, npgsql/npgsql#5166 already discussed this at the Npgsql level, and the issue was in any case with System.Text.Json itself requiring that $type
be the first property; that has been solved for 8.0.