Resolve dependencies in the MultiTenantConnectionBuilder method

Thanks for your response. I agree that we may not need dependencies scoped to each message. Instead, we could use dependencies that resolve a connection string based on the message’s tenant ID, and these dependencies can be resolved in a singleton scope.

This resolves one issue but brings up another question I posted in the community forum: Configuring NSB in .NET 8 using Generic Host Model and Web Hosting Model.

The need to resolve dependencies to create an EndpointConfiguration instance means I have to build the service collection to get a service provider before I can call IHostApplicationBuilder.UseNServiceBus(endpointConfiguration). However, when IHostApplicationBuilder.Build() is called, it will create another service provider for the .NET Core runtime to use.

I would appreciate hearing from the community on best practices for creating hosting endpoints in .NET 8.