Ninjects looks for constructors in the following order:
- Constructors marked with
[Inject]
- Construtors with the most parameter
- Default contructor
In your case your TLPContext
constructor is not marked with [Inject]
so the 2. rules applies and Ninject will try to resolve the base class contructor and then throws the exception.
So you can solve this by marking your constructor with the InjectAttribute
[Inject]
public TLPContext()
: base("DefaultConnection")
{
this.Configuration.LazyLoadingEnabled = false;
}
Or you can specify the constructor with the ToConstructor
method when registering your TLPContext
:
kernel.Bind<TLPContext>().ToConstructor(_ => new TLPContext());