title: Add element or add to array using MongoDB C# driver 2.0
body: <p>I have a document that can have a "Favorites" element on it and I'm trying to push a new value into an array on that element. However, I'm getting an error because the document I'm trying to update doesn't have the "Favorites" element. How can I create the element if it doesn't exist so I can push the new value into it's array property? Can I do it in one operation? Here's what I'm doing, but I get the error <code>cannot use the part (Favorites of Favorites.ProgramIds) to traverse the element ({Favorites: null})</code></p>
  
  <pre><code>var filter = Builders&lt;UserEntity&gt;.Filter.Eq(u =&gt; u.Id, userId);
  var update = isFavorite ? Builders&lt;UserEntity&gt;.Update.AddToSet(u =&gt; u.Favorites.ProgramIds, id)
      : Builders&lt;UserEntity&gt;.Update.Pull(u =&gt; u.Favorites.ProgramIds, id);
  await collection.UpdateOneAsync(filter, update);
  </code></pre>