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:

  1. Configure the POCO to NOT serialize the default _id value
[BsonIgnoreIfDefault]
[BsonGuidRepresentation(GuidRepresentation.Standard)]
public Guid Id { get; set; }
  1. 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.