 <p>I got the same problem using Robomongo. I solve it creating the function manually on shell.</p> <p>Right-click on your database -> Open Shell.</p> <pre><code>db.system.js.save({ _id : "getNextSequence" , value : function (name) { var ret = db.counters.findAndModify({ query: { _id: name }, update: { $inc: { seq: 1 } }, new: true }); return ret.seq; } }); </code></pre>