title: MassTransit - Saga repository with Entity Framework Core
body: <p>Thank you very much in advance.</p>
  <p>My projects are targeting .NET Core 2.2.</p>
  <p>I am trying to define a service that is using Masstransit 6.2.5, which uses SAGA Machine with a SQL database.</p>
  <p>Using this code</p>
  <pre><code>services.AddMassTransit(cfg =&gt;
                {
                    cfg.AddConsumersFromNamespaceContaining&lt;SubmitVolunteerConsumer&gt;(); //add consumer
                    cfg.AddSagaStateMachine&lt;UserStateMachine, UserState&gt;(typeof(UserStateMachineDefinition))
  
                    .EntityFrameworkRepository(r =&gt;
                    {
                        r.ConcurrencyMode = ConcurrencyMode.Pessimistic;
  
                        services.AddDbContext&lt;DbContext, UserStateDbContext&gt;((provider, build) =&gt;
                        {
                            build.UseSqlServer(connectionString, m =&gt;
                            {
                                m.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name);
                                m.MigrationsHistoryTable($&quot;__{nameof(UserStateDbContext)}&quot;);
                            });
                        });
  
                    });
  
                    cfg.AddBus(provider =&gt; RabbitMqBus.ConfigureBus(provider, false));
                });
  </code></pre>
  <p>causes an issue because it requires <code>MassTransit.EntityFrameworkCore</code> 6.2.5 (however, this is using <code>Microsoft.EntityFrameworkCore.Relational</code> (3.1.3)) which is causing an error when I am trying to call/use the DBContext</p>
  <p>Got this error</p>
  <blockquote>
  <p>Could not load type 'Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptionsExtensionWithDebugInfo' from assembly 'Microsoft.EntityFrameworkCore, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.</p>
  </blockquote>
  <p>Could you please help me find a way to use SQL Server with my Saga machine without using a Nuget that references Entity Framework Core 3.x?</p>
  <p>By the way, here is my Dbcontext</p>
  <pre><code>public UserStateDbContext(DbContextOptions options)
    : base(options)
  {
  }
  
  protected override IEnumerable&lt;ISagaClassMap&gt; Configurations
  {
      get { yield return new UserStateMap(); }
  }
  
  protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  {
      IConfigurationRoot configuration = new ConfigurationBuilder()
        .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
        .AddJsonFile(&quot;appsettings.json&quot;)
        .Build();
          optionsBuilder.UseSqlServer(configuration.GetConnectionString(&quot;GRPPortal&quot;));
  
  }
  </code></pre>