There is some legacy data that I have refactored to have a polymorphic structure:
class Shape {}
class Rectangle : Shape {}
class MyClass
{
public Shape shape;
}
BsonClassMap.RegisterClassMap<Shape>(cm =>
{
cm.AutoMap();
cm.SetIsRootClass(true);
cm.AddKnownType(typeof(Rectangle));
});
This works great for new data, the discriminator _t is created for shapes and rectangles accordingly. The problem I'm having is with legacy data which is all of type rectangle, but has no discriminator _t in the db since when it was created no polymorphism existed. When I try to read one of these objects, I get a deserialization error because it cannot map the legacy Rectangle to a Shape. I would prefer not to have to run a data migration to add the discriminator, is there a way for me to default the deserialization type to Rectangle if the discriminator is missing?