通过代码创建新集合时,添加新索引的调用失败:
private static void CreateCollection<T>(string collectionName, CreateIndexModel<T> index)
{
var database = GetMongoDatabase();
database.CreateCollection(collectionName);
var collection = database.GetCollection<T>(collectionName);
collection.Indexes.CreateOne(index); // Message=Command createIndexes failed
}