I’m using the EFCore provider (v8.2.3) to interact with Mongo. Something I can’t seem to figure out is how to save arbitrary JSON as a property of a document. I’ve tried BsonDocument
and Dictionary<string, object>
both fail with a message like the following:
‘Dictionary<string, object>’ property ‘MyEntity’ could not be mapped because the database provider does not support this type.
This seems like it should work (Dictionary<object, string>
anyway) because it looks like the serializer supports any Dictionary<,>
.
Dictionary<string, string>
does work but is not ideal since it only works for flat JSON (no nesting) and turns all values into strings.
Is there a way to accomplish what I am looking to do? I know I could store the JSON as a serialized string (and deserialize on read) but I’d prefer the JSON to be kept intact in Mongo.
Thanks in advance.