C# GUID Style dont work

Hi, Alexov,

When working with POCOs in the .NET/C# driver, different GUIDs within a single document can use different GUID representations, but all GUIDs for a single field (e.g. _id) must use the same representation. This is because we need to know how to map the array of bytes to fields within the GUID.

If your existing collection doesn’t contain a lot of data, the easiest solution is to create a new collection and migrate the existing data to it ensuring that all GUIDs use subtype 4. If your existing collection contains a substantial amount of data that you want to migrate on modification, you could implement your own IBsonSerializer that can read both subtype 3 and subtype 4 GUIDs but will always write as subtype 4.

Sincerely,
James

2 Likes