Insert a new field into an existing collection (many documents) in MongoDB using C# driver

c#, mongodb

Solution

Following code should work:

collection.Update(Query.Null, Update.Set("HomePhoneId", "some value"), UpdateFlags.Multi)

Btw, here is you can look into driver documentation.

Problem

How can I insert a new field into a MongoDB collection using the C# `Update` API? What I am trying to do: I have a `HomePhoneId` field that I need to insert into every document in my `People` collection. Any ideas?

Original source