title: MongoDb C# Driver Resolving Command insert failed: document does not contain shard key
body: <p>I am experimenting with MongoDB Api for CosmosDB and I have the following error while inserting a value in the database : </p>
  
  <blockquote>
    <p>Command insert failed: document does not contain shard key.</p>
  </blockquote>
  
  <p>I'm using cosmosdb emulator, My Partition Key is "Id" Here is a simple insert I tried :</p>
  
  <pre><code>        mongoCollection.InsertOne(new { Name = "John", Id = 007 });
  </code></pre>
  
  <p>To resolve this issue, I searched and saw this question : </p>
  
  <p><a href="https://stackoverflow.com/questions/45587691/comosdb-mongoapi-document-does-not-contain-shard-key">Similar to mine,</a></p>
  
  <p>I tried running the command specified in the answer to the question, as follows :</p>
  
  <pre><code>        var command = new BsonDocument("{ shardCollection: \"Mydb.collection1\", key: { Id: \"hashed\" } }", 1);
          database.RunCommand&lt;BsonDocument&gt;(command);
  </code></pre>
  
  <p>But it doesn't work and throws me another exception, Please can someone tell me what to do ?</p>