To delete a collection, you can use the DropCollectionAsync method.
Here is a sample code for dropping multiple collections defined by an array of names:
var client = new MongoClient(connectionString);
var database = client.GetDatabase(databaseName);
var collectionNames = new List<string> { "collection1", "collection2" };
foreach (var collectionName in collectionNames)
{
await database.DropCollectionAsync(collectionName);
}
2
Answers
To delete a collection, you can use the
DropCollectionAsync
method.Here is a sample code for dropping multiple collections defined by an array of names:
You may iterate collections and drop()