Polymorphism in RavenDB

RavenDB stores document in JSON format, which make it very flexible, but also make some code patterns harder to work with. In particular, the RavenDB Client API will not, by default, record type information into embedded parts of the JSON document. That makes for a much easier to read JSON, but it means that using polymorphism for objects that are embedded inside another document requires some modification.

Note

There is no problem with polymorphism for entities that are stored as documents, only with embedded documents.

That modification happens entirely at the JSON.Net layer, which is responsible for serializing and deserializing documents. The problem is when you have a model such as this: