Upgrading an old mvc2 legacy system to current .Net enviroment

Skip to first unread message

Jerker Pihl

Mar 17, 2021, 12:33:52 PM3/17/21
to structuremap-users
I wonder if its possible to use current structuremap (.Net 4.7.2) with an old MVC2 system. Iam thinking on dependency injection for controllers...
We have created an repository layer in a standard libary with entity framework core .
Current version of structuremap in system is (yes its pre nuget). The problem is that this old version of structuremap goes bonkers over IDbContextOptionsExtension

StructureMap Exception Code:  202
No Default Instance defined for PluginFamily System.Collections.Generic.IReadOnlyDictionary`2[[System.Type, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089],[Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptionsExtension, Microsoft.EntityFrameworkCore, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60]], mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

I dont understand why but my guess the structuremap is just to old to handle this. 
So thats why question if its possible to use newest structuremap with old mvc2 controllers and dependecy injection? (how would that even look?)
If not any suggestions?

Jeremy Miller

Mar 17, 2021, 3:45:36 PM3/17/21
to structuremap-users
Okay, so a couple things:

1. StructureMap is no longer supported, see Lamar, but you'd have to go back a major version because I dropped support for anything < .Net Core 3.1 in the latest release
2. StructureMap can certainly "handle" MVC, but you're probably going to have to help it out by selecting the right constructor of EF Core up above. The exception is telling you there's a missing service registration that the IDbContextOptionsExtension needs
3. You can use the latest StructureMap with any version of pre-ASP.Net Core MVC

Jerker Pihl

Mar 18, 2021, 6:06:41 AM3/18/21
to structuremap-users
Thanks for your answer. The problem will(?) be solved if I get structuremap to ignore IDbContextOptionsExtension but is that possible with such a old version?
Reply all
Reply to author
0 new messages