using System; using System.Collections.Generic; using System.Linq; using System.Text; using MongoDB.Bson; using MongoDB.Driver; using MongoDB.Driver.Builders; namespace TestCSharp510 { public static class Program { public static void Main(string[] args) { var server = MongoServer.Create("mongodb://localhost/?safe=true"); var database = server.GetDatabase("test"); database.Drop(); var keys = IndexKeys.Ascending("Name"); var options = IndexOptions.SetUnique(true).SetDropDups(false); database.GetCollection("categories1").CreateIndex(keys, options); database.GetCollection("categories2").CreateIndex(keys, IndexOptions.SetUnique(true).SetDropDups(false)); } } }