You can't register things in the container after it's built.
On line 11 in the sample for Application_Start
you're building the container, but then after you set the DependencyResolver
you're registering more stuff with the ContainerBuilder
. You can't do that - you have to register everything first, then build the container as the last thing you do.
That's why it's never entering your PersistenceModule
- you've already built the container, so it's not actually getting registered.
If, for some reason, you need to add registrations to an already-built container, you need to create an all new ContainerBuilder
and call builder.Update(container)
. However, I strongly recommend you just reorder things so the container is built last rather than go the Update
route if possible.