Method CreateCollection
CreateCollection(string)
Creates a collection. MongoDB creates collections automatically when they are first used, so this command is mainly here for frameworks.
public virtual CommandResult CreateCollection(string collectionName)
Parameters
collectionName
stringThe name of the collection.
Returns
- CommandResult
A CommandResult.
CreateCollection(string, IMongoCollectionOptions)
Creates a collection. MongoDB creates collections automatically when they are first used, so you only need to call this method if you want to provide non-default options.
public virtual CommandResult CreateCollection(string collectionName, IMongoCollectionOptions options)
Parameters
collectionName
stringThe name of the collection.
options
IMongoCollectionOptionsOptions for creating this collection (usually a CollectionOptionsDocument or constructed using the CollectionOptions builder).
Returns
- CommandResult
A CommandResult.