Connection string exception after upgrading to Ninject 3.0.0-rc3

I recently upgraded my website project to Ninject 3.0.0-rc3, and after that I get errors saying: "The supplied connection is not valid because it contains insufficient map information or metadata." All this worked when I used version 2.2.0.0.

Any idea what could throw this exception, and also how can I solve it?

I am using EF and my backend is SQL Server 2008 R2.

+1
ninject
source share
1 answer

I had the same problem and fixed it by switching to the NinjectHttpApplication extension, and not to the NinjectWebCommon.cs approach. See https://github.com/ninject/ninject.web.mvc/wiki/Setting-up-an-MVC3-application for more details.

For the Ninject 3 update to work, I had to add the following bindings to my binding modules:

  Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel); Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>(); 

I think the root of the problem is that NinjectWebCommon.cs starts before the application is fully aware of its own context, so the Entity Framework cannot figure out how to parse connection strings if the context is created as part of a custom binding. This will not be a problem for many projects, but our system uses the database configuration to determine which Ninject modules are loaded first. The global Application_Start method is supposedly called at some later point in the application life cycle, so setting up bindings in Global works just fine.

+1
source share

All Articles