Method EnsureIndex
EnsureIndex(IMongoIndexKeys, IMongoIndexOptions)
Ensures that the desired index exists and creates it if it does not.
[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(IMongoIndexKeys keys, IMongoIndexOptions options)
Parameters
keys
IMongoIndexKeysThe indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).
options
IMongoIndexOptionsThe index options(usually an IndexOptionsDocument or created using the IndexOption builder).
EnsureIndex(IMongoIndexKeys)
Ensures that the desired index exists and creates it if it does not.
[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(IMongoIndexKeys keys)
Parameters
keys
IMongoIndexKeysThe indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).
EnsureIndex(params string[])
Ensures that the desired index exists and creates it if it does not.
[Obsolete("Use CreateIndex instead.")]
public virtual void EnsureIndex(params string[] keyNames)
Parameters
keyNames
string[]The names of the indexed fields.