Upgrading MediatR 2 to 3
Breaking2.1.0 → 3.0.1Breaking3New1Fixed1
BreakingUpgrade verdict
3 breaking changes.
In plain terms
- Handlers can no longer inherit from a RequestHandler base class; implement the interfaces instead.
- All mediator calls now return tasks and can be cancelled; there are no synchronous versions anymore.
- You no longer create separate sync and async request types; MediatR picks the right handler based on the handler interface you implement.
Must act 3 items need code or config changes
What you must change
Breaking3
The RequestHandler base class is removed, leaving only the handler interfaces.
RequestHandlerThe IMediator interface is now async-only, with optional cancellation tokens and no sync overloads.
IMediatorSendPublishRequest and notification types are now just IRequest or INotification; handlers are chosen by IRequestHandler, IAsyncRequestHandler and ICancellableAsyncRequestHandler.
IRequestINotificationIRequestHandlerIAsyncRequestHandlerICancellableAsyncRequestHandler