# Ninject > [!WARNING] > Starting with NServiceBus version 7, the dependency injection container adapter packages are no longer required. NServiceBus directly supports the `Microsoft.Extensions.DependencyInjection` model and third party containers can be integrated using the [NServiceBus.Extensions.DependencyInjection package](/nservicebus/dependency-injection/extensions-dependencyinjection.md) or via the [.NET Generic Host](https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host). > > In NServiceBus version 8, NServiceBus will no longer provide adapters for external dependency injection containers. > > Visit the [dependency injection upgrade guide](/nservicebus/upgrades/7to8/dependency-injection.md) for further information. NServiceBus can be configured to use [Ninject](http://www.ninject.org/) for dependency injection. ### Default usage ```cs endpointConfiguration.UseContainer(); ``` ### Using an existing kernel ```cs var kernel = new StandardKernel(); kernel.Bind() .ToConstant(new MyService()); endpointConfiguration.UseContainer( customizations: customizations => { customizations.ExistingKernel(kernel); }); ``` ### Unit of work When registering components with `configuration.RegisterComponents(...)`, it is possible to bind a service using a _Unit of Work_ scope, which corresponds to the `DependencyLifecycle.InstancePerUnitOfWork` lifecycle. In essence, bindings using _Unit of Work_ scope - will be instantiated only once per transport message - will be disposed when message processing finishes Bind the services in _Unit of Work_ scope using: ```cs var kernel = new StandardKernel(); kernel.Bind() .ToSelf() .InUnitOfWorkScope(); ``` Services using `InUnitOfWorkScope()` can only be injected into code which is processing messages. To inject the service somewhere else (e.g. because of a user interaction) define conditional bindings: ```cs var kernel = new StandardKernel(); // always create a new instance when not processing a message kernel.Bind().ToSelf() .WhenNotInUnitOfWork() .InTransientScope(); // always use the same instance when processing messages kernel.Bind().ToSelf() .WhenInUnitOfWork() .InSingletonScope(); ``` Funcs can only be injected when using the [ContextPreservation Ninject extension](https://github.com/ninject/Ninject.Extensions.ContextPreservation/). ```cs var kernel = new StandardKernel(); kernel.Bind() .ToMethod(ctx => ctx.ContextPreservingGet()) .InUnitOfWorkScope(); ``` ### Multi hosting Multiple endpoints in a single process cannot share a single Ninject kernel. Each one requires its own container instance or its own child container. Ninject supports this with the [Ninject.Extensions.ChildKernel](https://github.com/ninject/Ninject.Extensions.ChildKernel) extension. Execute `new ChildKernel(parentKernel)` and pass this new kernel instance to NServiceBus. ### DependencyLifecycle Mapping [`DependencyLifecycle`](/nservicebus/dependency-injection/index.md) maps to [Ninject object scopes](https://github.com/ninject/ninject/wiki/Object-Scopes) as follows: | `DependencyLifecycle` | Ninject object scope | |-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| | [InstancePerCall](/nservicebus/dependency-injection/index.md#service-registrations-instance-per-call) | [Transient](https://github.com/ninject/ninject/wiki/Object-Scopes) | | [InstancePerUnitOfWork](/nservicebus/dependency-injection/index.md#service-registrations-instance-per-unit-of-work) | [Singleton](https://github.com/ninject/ninject/wiki/Object-Scopes) within a [Named Scope](https://github.com/ninject/ninject.extensions.namedscope/wiki) per Unit of Work | | [SingleInstance](/nservicebus/dependency-injection/index.md#service-registrations-single-instance) | [Singleton](https://github.com/ninject/ninject/wiki/Object-Scopes) | ## Property Injection This dependency injection container adapter automatically enables property injection for known types. Use the `Func` overload of `.ConfigureComponent` to get full control over the injected properties if needed.