Mongodb - Element '_id' does not match any field or property of class -
Getting this error when trying to query from my mongodb collection.
Element '_id' does not match any field or property of class.
Since I still wanted to work with the extra field _id, i would want to include additional field in there.
public class Restaurant
{
[BsonId]
public MongoDB.Bson.ObjectId _id { get; set; }
public string borough { get; set; }
public string cuisine { get; set; }
}
Sometimes you might want to consider ignoring additional field.
[BsonIgnoreExtraElements]
public class Restaurant
{
[BsonId]
public MongoDB.Bson.ObjectId _id { get; set; }
public string borough { get; set; }
public string cuisine { get; set; }
}
Comments