private static void RecreateDatabaseAndInstallObjects() { using (var context = ConnectionUtils.CreateConnection()) { try { context.Init(new MongoStorageOptions()); context.DistributedLock.DeleteMany(new BsonDocument()); context.StateData.DeleteMany(new BsonDocument()); context.Job.DeleteMany(new BsonDocument()); context.JobQueue.DeleteMany(new BsonDocument()); context.Server.DeleteMany(new BsonDocument()); } catch (MongoException ex) { throw new InvalidOperationException("Unable to cleanup database.", ex); } } }