In a Web API, I have a service that depends on IMessageSession. However, the pipeline used to send messages does not have access to the scoped ServiceProvider.
I have implemented Behavior<IOutgoingLogicalMessageContext> and want to access our scoped TenantProvider to set a tenant header on outgoing messages. The problem is that the ServiceProvider available in the pipeline is the root container; hence, trying to resolve a scoped service results in an exception.
var scopedProvider = context.Extensions.Get<IServiceProvider>();
var tenantProvider = scopedProvider.GetRequiredService<TenantProvider>();
Is this expected?