Skip to content

Commit

Permalink
Fix DbContext Registration for Activities
Browse files Browse the repository at this point in the history
  • Loading branch information
maldworth committed May 19, 2020
1 parent a8bcbf1 commit ca91e77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
public class CancelOrderActivity :
IExecuteActivity<CancelOrderArguments>
{
private readonly SampleBatchDbContext _dbContext;
readonly ILogger _logger;

public CancelOrderActivity(ILoggerFactory loggerFactory)
public CancelOrderActivity(SampleBatchDbContext dbContext, ILoggerFactory loggerFactory)
{
_dbContext = dbContext;
_logger = loggerFactory.CreateLogger<CancelOrderActivity>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
public class SuspendOrderActivity :
IExecuteActivity<SuspendOrderArguments>
{
private readonly SampleBatchDbContext _dbContext;
readonly ILogger _logger;

public SuspendOrderActivity(ILoggerFactory loggerFactory)
public SuspendOrderActivity(SampleBatchDbContext dbContext, ILoggerFactory loggerFactory)
{
_dbContext = dbContext;
_logger = loggerFactory.CreateLogger<SuspendOrderActivity>();
}

Expand Down
2 changes: 1 addition & 1 deletion src/SampleBatch.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static async Task Main(string[] args)
cfg.AddBus(ConfigureBus);
});

services.AddDbContext<DbContext, SampleBatchDbContext>(x => x.UseSqlServer(hostContext.Configuration.GetConnectionString("sample-batch")));
services.AddDbContext<SampleBatchDbContext>(x => x.UseSqlServer(hostContext.Configuration.GetConnectionString("sample-batch")));

services.AddHostedService<MassTransitConsoleHostedService>();

Expand Down

0 comments on commit ca91e77

Please sign in to comment.