Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# MongoDB -> MongoDatabase.Drop() doesn't delete the db itself

Tags:

c#

mongodb

I am trying to completely remove a database (delete all collections and the db itself).

When I do it from Robomongo (right click on the db -> drop database) it works as expected, but when using the driver from c# it just removes all collections of the db.

The method I am calling is: MongoDatabase.Drop(). I am using MongoDB.Driver in .Net 4.5.

like image 881
Guy Katznelson Avatar asked Feb 02 '15 13:02

Guy Katznelson


1 Answers

Just for sake of completeness, the driver v2.3 has:

var client = new MongoClient(connectionString);
client.DropDatabase(dbName);
like image 63
Alexey Zimarev Avatar answered Oct 21 '22 14:10

Alexey Zimarev