This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11224|Reply: 1

{"Element '_id' does not match any field or property of class."}

[Copy link]
Posted on 10/8/2016 4:17:28 PM | | |
{"Element '_id' does not match any field or property of class."}
System.AggregateException: One or more errors occurred. ---> System.FormatException: Element '_id' does not match any field or property of class MongoDBCRUD.Program+BOSBourse. at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext context)

[...]

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at MongoDBCRUD.Program.d__1.MoveNext() in C:\Users\amin-\Documents\Visual Studio 2015\Projects\MongoDBCRUD\ MongoDBCRUD\Program.cs:line 60<---




public ObjectId _id { get; set; }

This must be there, and if there are fields in the database, the object must define what attributes, and the type of the attributes must be the same as the type stored in the database.

What a pit!!! Otherwise, an exception will be thrown




Previous:_id queries using MongoDB
Next:C# programs run with administrator privileges
 Landlord| Posted on 10/8/2016 5:30:53 PM |
_id property must be there, otherwise an error will be reported when updating the data: "Element '_id' does not match any field or property of class".
        public ObjectId _id; BsonType.ObjectId corresponds to MongoDB.Bson.ObjectId
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com