Hi @Ondrej_Svacina ,
What you’re mentioning is possible. Looking at the error while trying to replicate this, this is happening because the default value of the _id is being serialized. There are two ways of doing this type of upsert:
- Configure the POCO to NOT serialize the default
_id value
[BsonIgnoreIfDefault]
[BsonGuidRepresentation(GuidRepresentation.Standard)]
public Guid Id { get; set; }
- Assign the
_id value for the new entity to be same as the one you are trying to replace.
As you can see in the replacement parameter here, The <replacement> document cannot specify an _id value that differs from the replaced document.
We’ll update our documentation to clarify this further. Let me know if that works for you.
Thanks,
Rishit.