-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
Using MongoDB Driver version 2.19
The error (MongoDB.Bson.BsonSerializationException: 'An error occurred while serializing the students property of class PatientJourney.ExamModel: Element name '$ref' is not valid'.') is thrown when calling the method _collection.ReplaceOneAsync(filter,model) with students.length >1 which dataType is List<MongoDBRef>.
The error is not thrown when using the method _collection.InsertOneAsync(model) and when the length of the MongoDBRef List is not larger than 1 in the _collection.ReplaceOneAsync(filter,model) method. Note that the same model is passed to InsertOneAsync method and ReplaceOneAsync method