static void CreateIndexes(MongoPersistenceProvider instance)
        {
            if (!indexesCreated)
            {
                instance.WorkflowInstances.Indexes.CreateOne(new CreateIndexModel <WorkflowInstance>(
                                                                 Builders <WorkflowInstance> .IndexKeys.Ascending(x => x.NextExecution),
                                                                 new CreateIndexOptions {
                    Background = true, Name = "idx_nextExec"
                }));

                instance.Events.Indexes.CreateOne(new CreateIndexModel <Event>(
                                                      Builders <Event> .IndexKeys.Ascending(x => x.IsProcessed),
                                                      new CreateIndexOptions {
                    Background = true, Name = "idx_processed"
                }));

                instance.Events.Indexes.CreateOne(new CreateIndexModel <Event>(
                                                      Builders <Event> .IndexKeys
                                                      .Ascending(x => x.EventName)
                                                      .Ascending(x => x.EventKey)
                                                      .Ascending(x => x.EventTime),
                                                      new CreateIndexOptions {
                    Background = true, Name = "idx_namekey"
                }));

                instance.EventSubscriptions.Indexes.CreateOne(new CreateIndexModel <EventSubscription>(
                                                                  Builders <EventSubscription> .IndexKeys
                                                                  .Ascending(x => x.EventName)
                                                                  .Ascending(x => x.EventKey),
                                                                  new CreateIndexOptions {
                    Background = true, Name = "idx_namekey"
                }));

                instance.ScheduledCommands.Indexes.CreateOne(new CreateIndexModel <ScheduledCommand>(
                                                                 Builders <ScheduledCommand> .IndexKeys
                                                                 .Descending(x => x.ExecuteTime),
                                                                 new CreateIndexOptions {
                    Background = true, Name = "idx_exectime"
                }));

                instance.ScheduledCommands.Indexes.CreateOne(new CreateIndexModel <ScheduledCommand>(
                                                                 Builders <ScheduledCommand> .IndexKeys
                                                                 .Ascending(x => x.CommandName)
                                                                 .Ascending(x => x.Data),
                                                                 new CreateIndexOptions {
                    Background = true, Unique = true, Name = "idx_key"
                }));

                indexesCreated = true;
            }
        }
 static void CreateIndexes(MongoPersistenceProvider instance)
 {
     if (!indexesCreated)
     {
         instance.WorkflowInstances.Indexes.CreateOne(Builders <WorkflowInstance> .IndexKeys.Ascending(x => x.NextExecution), new CreateIndexOptions()
         {
             Background = true, Name = "idx_nextExec"
         });
         instance.Events.Indexes.CreateOne(Builders <Event> .IndexKeys.Ascending(x => x.IsProcessed), new CreateIndexOptions()
         {
             Background = true, Name = "idx_processed"
         });
         indexesCreated = true;
     }
 }