 <p>Here's what worked for me, building on @Ross's answer, which didn't quite work for me:</p> <pre><code>import com.mongodb.casbah.Imports._ // Connect to MongoDB val conn = MongoClient() val adminDB = conn("admin") // Enable sharding on the DB adminDB.command(MongoDBObject("enableSharding" -&gt; &lt;database&gt;)) // Create the index for our shard key val shardKey = MongoDBObject("_id" -&gt; "hashed") conn(&lt;database&gt;)(&lt;collection&gt;).ensureIndex(shardKey) // Enable sharding on the collection adminDB.command(MongoDBObject("shardCollection" -&gt; "&lt;database&gt;.&lt;collection&gt;", "key" -&gt; shardkey)) </code></pre>