title: MassTransit Redis integration
body: <p>I'm starting to work with Masstransit sagas and I built an example, if I use InMemorySagaRepository everything works fine, but when use Redis repository the Increase message is moved to the Consumer_Error queue in RabbitMq with the error message: 'Value cannot be null. Parameter name: key' and this stack trace:</p>
  
  <pre><code>at System.Collections.Generic.Dictionary`2.FindEntry(TKey key) 
  at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue&amp; value) 
  at Automatonymous.AutomatonymousStateMachine`1.GetState(String name) 
  at Automatonymous.Accessors.RawStateAccessor`1.Automatonymous.StateAccessor&lt;TInstance&gt;.Get(InstanceContext`1 context) 
  at Automatonymous.Accessors.InitialIfNullStateAccessor`1.&lt;Automatonymous-StateAccessor&lt;TInstance&gt;-Get&gt;d__3.MoveNext() 
  at Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.&lt;Send&gt;d__5.MoveNext() 
  at GreenPipes.Filters.ConcurrencyLimitFilter`1.&lt;Send&gt;d__5.MoveNext() 
  at MassTransit.RedisIntegration.RedisSagaRepository`1.&lt;SendToInstance&gt;d__7`1.MoveNext()
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>public class SagaConsumer : MassTransitStateMachine&lt;Number&gt;
  {
      public SagaConsumer()
      {
          State(() =&gt; Active);
  
          InstanceState(x =&gt; x.Status);
  
          Event(() =&gt; Created); 
          Event(() =&gt; Increased);
  
          Initially(
                      When(Created)
                      .Then(context =&gt;
                      {
                          context.Instance.Name = context.Data.Name;
                          context.Instance.Value = 0;
                      })
                      .ThenAsync(context =&gt; Console.Out.WriteLineAsync($"New name:{context.Data.Name}"))
                      .TransitionTo(Active)
                  );
  
          During(Active,
                      When(Increased)
                      .Then(context =&gt;
                      {
                          context.Instance.Value = context.Data.Increase ? context.Instance.Value + 1 : context.Instance.Value - 1;
                       })
                      .ThenAsync(context =&gt; Console.Out.WriteLineAsync($"{context.Instance.Name} increased to value {context.Instance.Value}"))
                 );
      }
  
      public State Active
      {
          get; set;
      }
  
      public Event&lt;ICreateMessage&gt; Created { get; set; }
      public Event&lt;IIncreaseMessage&gt; Increased { get; set; }
  }
  </code></pre>
  
  <p>And the configuration code:</p>
  
  <pre><code>var bus = Bus.Factory.CreateUsingRabbitMq(configurator =&gt;
  {
      var host = configurator.Host(new Uri("rabbitmq://localhost"), h =&gt;
      {
         h.Username("guest");
         h.Password("guest");
      });
  
      var redisManager = new PooledRedisClientManager("localhost");
      configurator.ReceiveEndpoint("Consumer", endpoint =&gt;
      {
          endpoint.StateMachineSaga(new SagaConsumer(), 
                                      //new InMemorySagaRepository&lt;Number&gt;(),
                                      new RedisSagaRepository&lt;Number&gt;(redisManager),
                                      c =&gt; c.UseConcurrencyLimit(10));
      });                
  });
  </code></pre>
  
  <p>And Saga class:</p>
  
  <pre><code>public class Number : SagaStateMachineInstance, IHasGuidId, IVersionedSaga, CorrelatedBy&lt;Guid&gt;
  {
      public Guid CorrelationId
      {
          get;
          set;
      }
  
      public string Name { get; set; }
      public State Status { get; set; }
      public int Value { get; set; }
      public int Version { get; set; }
  
      public Guid Id
          =&gt; CorrelationId;
  }
  </code></pre>
  
  <p>It seems to be related to the Status property of Number class that is null at some point but I'm not sure why or why it's happening only when using Redis</p>