add a dynamic serializer that automatically chooses the downcast model to serialize