MassTransit with Mediator – ‘IServiceCollectionBusConfigurator’ does not contain a definition for ‘AddMediator’ and the best extension method overload ‘DependencyInjectionRegistrationExtensions.AddMediator(IServiceCollection, Action)’ requires a receiver of type ‘IServiceCollection’

Hi everyone,

I’m currently learning MassTransit by following a great video series by Chris Patterson: https://www.youtube.com/watch?v=dxHNAn69x6w&list=PLx8uyNNs1ri2MBx6BjPum5j9_MMdIfM9C&index=1. Unfortunately, when trying to add mediator as instructed in the first video I hit the following error:

‘IServiceCollectionBusConfigurator’ does not contain a definition for ‘AddMediator’ and the best extension method overload ‘DependencyInjectionRegistrationExtensions.AddMediator(IServiceCollection, Action)’ requires a receiver of type ‘IServiceCollection’

After a bit of Googling I came across some upgrade documentation with the following highlight:

Container configuration has changed, and now uses the AddMediator method (instead of AddMassTransit).

The solution ended up being as follows:

services.AddMediator(x =>
{
x.AddConsumersFromNamespaceContaining();
x.AddRequestClient();
});

Thanks to this link for the info: https://masstransit-project.com/getting-started/upgrade-v6.html#version-7


Posted

in

by

Tags:

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: