title: MongoDb c# .net Save throwing duplicate key exception
body: <p>I don't understand why I am getting a duplicate key exception on Save. I thought the point of save was to update if there, insert if not. Here is the error.</p>
  
  <blockquote>
    <p>WriteConcern detected an error 'E11000 duplicate key error index: cms.BaseVariables.$<em>id</em>  dup key: { : "8f69cb40ab3568957c237ef360d29964" }'. (Response was { "err" : "E11000 duplicate key error index: cms.BaseVariables.$<em>id</em>  dup key: { : \"8f69cb40ab3568957c237ef360d29964\" }", "code" : 11000, "n" : 0, "connectionId" : 6969, "ok" : 1.0 }).</p>
  </blockquote>
  
  <p>Yes it is right, 8f69cb40ab3568957c237ef360d29964 is there already. So why is it not just updating it?</p>
  
  <p>I have the following class map registration and ID property on the object...</p>
  
  <pre><code>BsonClassMap.RegisterClassMap&lt;BaseVariableGroup&gt;(cm =&gt;
  {
      cm.AutoMap();
      cm.SetIdMember(cm.GetMemberMap(c =&gt; c.Id));
      cm.IdMemberMap.SetIdGenerator(StringObjectIdGenerator.Instance);
  });
  
  public string Id
  {
      get { return _id; }
      set
      {
          _id = value;
          _id = Md5Cryptography.Hash(string.Concat(SportId, CompetitionId, Round));
      }
  }
  </code></pre>
  
  <p>And this is how I am calling Save...</p>
  
  <pre><code>_collection.Save(baseVariableGroup)
  </code></pre>
  
  <p>The exception...</p>
  
  <p><img src="https://i.stack.imgur.com/qnkMZ.png" alt="enter image description here"></p>