views:

188

answers:

1

I have a repository Class which takes in a ObjectContext called "TestDB". I when I launch my web application i'm getting a "Unable to load the specified metadate resource", almost like its not picking up the connection settings from my web.config file anymore.

Here is a snippet of my code.

[Inject]
public SqlCatelogRepository(){
   _dataContext = new SQLDb(); 
   //EF Entity, should pickup connection settings from web.config
}

Once get what is going on there I would like to pass in my DataContenxt but I can't seem to wrap my head around how this should look in the Ninject Mapping.

+1  A: 

Try something like:

[Inject]
public SqlCatelogRepository(){
   _dataContext = kernel.Get<SQLDb>(); 
   //EF Entity, should pickup connection settings from web.config
}

This will give NInject a chance to intercept your activation. Then your mappings can apply.

You might want to check out the "Service Locator" approach that Nate wrote about: http://kohari.org/2008/06/18/playing-nice-with-service-locators

Brett Veenstra