ASP.NET Core MediatR error: Register your handlers with the container

I have met the same issue.

The problem is that this line code

services.AddMediatR(typeof(AddEducationCommand).GetTypeInfo().Assembly);

handles all the MediatR IRequest and IRequestHandlers.

but you created an IRepository interface and its implementation class which can’t be handled by that MediatR.Extensions.Microsoft.DependencyInjection

so keep all your changes but add this – manually register this like

services.AddScoped(typeof(IUniversityRepository), typeof(UniversitySqlServerRepository));

then issue resolved.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)