C# Best Practice Codeshare between Create and Update/Set

Hello Dear MongoDB Community,

I just got started and one issue I have right now is how to Share code between Create and update operations - also in regard to Pocos

I have a Method for example AddAdress, which adds a Adress to a Person. It can either take a Person that already exists or which is not yet created.

Now in Entity Framework I just pass a Person Object and Change tracking of Entity Framework will track all changes to the object. If I then call Save the object is created or a update is generated with the changes.

Now in the MongoDB Driver there is only the Replace One functionality, which seems to me not recommendable since it replaces the whole object, instead of just making the changes.

Update then has completly different semantics to create and makes use of Pocos difficult.

Now before I write my own wrapper over Bson documents to be used for create and update, what is the best practice for this to realize? Instead of writing code twice, once for update and once for create. Or is there a change tracking?

Thank you very much

Greetings
Michael