Search code examples
c#mongodbmongodb-.net-driver

How to check if collection exists in MongoDB using C# driver?


Is there any way in C# to check if a collection with a specific name already exists in my MongoDB database?


Solution

  • You can do it like this:

    database.GetCollection("blah").Exists()