The entirety of the commonly used BsonDefaults method of setting GuidRepresentation has been marked obsolete while the documentation still refers to it and neither the "obsolete" warning or xmldoc inform you of what the replacement is beyond the vague statement `[Obsolete("Configure serializers instead.")]`
The following example will fail with `MongoDB.Driver.MongoCommandException: 'Command findAndModify failed: After applying the update, the (immutable) field '_id' was found to have been altered to _id: UUID("45206b70-146b-4947-9de2-aaab99c2223b").'`
Appending `?uuidRepresentation=Standard` to the connection string and the upsert will work as expected (previous behaviour); as would setting `BsonDefaults.GuidRepresentation = GuidRepresentation.Standard;` both of these configurations correctly store the ID as UUID() in mongo.
Swapping BSONID for [BsonRepresentation(BsonType.Binary)] will allow the code to run otherwise unaltered but then stores the ID as BinData(3, "a1A8tGgqy0myU3jvfIW3wQ==")
Changing the ID field to [BsonId, BsonGuidRepresentation(GuidRepresentation.Standard)]
results in the immutable id error again.
We appear to have gone from one line of code to configure ID storage to config roulette.
Its hard to tell if this is an underlying driver issue, a lack of validation or just a communication/documentation issue; the commit messages around the change don't shine much light on it either. ( `
CSHARP-2724: Implement specification for handling native UUID types. `
https://github.com/mongodb/mongo-csharp-driver/commit/b0b11348e1fb2418ca6a5999a2494db54ec186e5 ) the addition of new code that is immediately marked as obsolete also muddies the water a tad.