Hey everyone,
I ran into the following error today while searching MongoDb for an object:
Element ‘Tags’ does not match any field or property of class X.
The issue was that there were extra fields on the returned document that were not specified on the mapping target object. A bit of Googling revealed that there is a provided attribute that allows you to ignore all extra fields.
Simply add [BsonIgnoreExtraElements] to any relevant model definitions.
Thanks to this stackoverflow post for the lead: https://stackoverflow.com/a/23448987/522859
Leave a Reply