This is what i found out.
In my StartUp.cs, i have below code
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
IContainer container = new Container(rules => rules.WithTrackingDisposableTransients());
RegisterServices(container);
container = container.WithMvc();
ConfigureAuth(app);
}
public static void RegisterServices(IRegistrator registrator)
{
registrator.Register(typeof(IxxxRepository), typeof(xxxRepository), Reuse.Singleton);
}
}
In my WebApiConfig.cs
var c = new Container()
.WithWebApi(config, throwIfUnresolved: type => type.IsController());
c.Register(typeof(IxxxRepository), typeof(xxxRepository), Reuse.Singleton);
Both controllers (MVC and API) are working fine now. But i am not sure if this is the right way.Because now i will need to register repositories for each instance of both containers.