I have an entity class which can change over period of time. As of now, I binary serialization to serialize an object of this class. But if I add a new property to the class, I can't deserialize a stream serialized earlier. I tried if I can use BSON
with json.net
.
I need to take care of these things:
- Memory footprint of serialized data should be low
- serialization and deserialization should be fast
- Need to provide backward compatibility for data serialized with old entity class structure
One approach I considered is to convert the object to IDictionary
before serializing it so that I can set default value to properties that are not matching while deserializing. While this works well, it involves additional step to convert the object to IDictionary
.
Has anyone faced this situation? what are the approaches you use?