I am using C# MongoDB.Driver, Version=1.10.1.73.
Note I am aware of this question, not my issue whatsoever.
Error message:
MongoDB.Driver.MongoWriteConcernException: Command 'createIndexes' failed: exception: Index with name: filename_1_uploadDate_1 already exists with different options (response: { "createdCollectionAutomatically" : false, "numIndexesBefore" : 4, "errmsg" : "exception: Index with name: filename_1_uploadDate_1 already exists with different options", "code" : 85, "ok" : 0.0 })
MongoDatabase _database;
var query = MongoDB.Driver.Builders.Query.And(
MongoDB.Driver.Builders.Query.EQ(ColumnFilename, filePath),
MongoDB.Driver.Builders.Query.EQ(ColumnWidth, width),
MongoDB.Driver.Builders.Query.EQ(ColumnHeight, height));
var mongoFileInfo = _database.GridFS.FindOne(query);
if (mongoFileInfo != null) {
var mongoStream = mongoFileInfo.OpenRead();
if (/*some condition*/) {
mongoStream.Close();
mongoStream.Dispose();
mongoFileInfo.Delete(); // exception here
}
Full stack trace:
MongoDB.Driver.MongoCollection.CreateIndex(IMongoIndexKeys keys, IMongoIndexOptions options)
MongoDB.Driver.MongoCollection.CreateIndex(IMongoIndexKeys keys)
MongoDB.Driver.MongoCollection.CreateIndex(String[] keyNames)
MongoDB.Driver.GridFS.MongoGridFS.EnsureIndexes(Int32 maxFiles)
MongoDB.Driver.GridFS.MongoGridFS.EnsureIndexes()
MongoDB.Driver.GridFS.MongoGridFSFileInfo.Delete()