'IServiceCollection' does not contain a definition for 'AddMediatR' and no accessible extension method 'AddMediatR' accepting

Viewed 1385

I'm using .NET 6 in Program.cs:

builder.Services.AddMediatR(Assembly.GetExecutingAssembly());

I get: 'IServiceCollection' does not contain a definition for 'AddMediatR' and no accessible extension method 'AddMediatR' accepting a first argument of type 'IServiceCollection' could be found' (are you missing a using directive or an assembly reference?)

Why?

1 Answers

First you must

Install-Package MediatR

then for access in IServiceCollection must

Install-Package MediatR.Extensions.Microsoft.DependencyInjection
Related