There are two things you can do to deserialize this class and not fail
because of the extra element:
1. Use the [BsonIgnoreExtraElements] attribute:
[BsonIgnoreExtraElements]
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
}
2. If you want to stay away from attributes on your POCOs use the
following during the initialization of your application:
BsonClassMap.RegisterClassMap<Person>(cm => {
cm.AutoMap();
cm.SetIgnoreExtraElements(true);
});
Keep in mind that RegisterClassMap can only be called once per type.
Do you think the default should be to ignore extra elements? My though
was that it was better to default on the side of safety (how do we
know it's safe to ignore extra elements?).