Fork me on GitHub

Integrating StructureMap into Common .Net Frameworks Edit on GitHub


Want to see more integrations or samples of how to integrate StructureMap with various .Net development tools? Let us know in Gitter or Github, or better yet, we take pull requests for documentation.

ASP.NET MVC 5

The StructureMap team recommends the StructureMap.MVC5 NuGet package for integrating StructureMap into ASP.NET MVC. The design is necessarily odd to work around ASP.NET limitations, but you do get the all important "nested container per HTTP request" pattern that we recommend.

ASP.NET Web API

The easiest way to integrate StructureMap with ASP.NET Web API is with the WebApi.StructureMap NuGet package. This package requires StructureMap 4.1 or higher. Use the StructureMap.WebApi2 NuGet package for older versions of StructureMap or combined ASP.NET MVC and Web API projects where you already use the StructureMap.MVC5 NuGet package.

ASP.NET Core

See the StructureMap.Microsoft.DependencyInjection project and NuGet package for integration with ASP.NET Core.

NServiceBus

Use the NServiceBus StructureMap NuGet package for integrating StructureMap 3 into NServiceBus.

NancyFx

NancyFx provides the Nancy.Bootstrappers.StructureMap NuGet package. The early versions of the NancyFx integration with StructureMap were deeply flawed but improved in later versions, so do make sure that you are using the latest version of the bootstrapper.

MassTransit

Use the MassTransit.StructureMap NuGet package. Unfortunately, this package depends on the signed version of StructureMap, so prepare yourself for version conflicts, binding redirects, and the fusion log viewer. See the MassTransit documentation on using StructureMap for more information.

Entity Framework

The best example is this blog post from Jimmy Bogard.

AutoMapper

See My AutoMapper setup for StructureMap from Martijn Burgers.