ninject/Ninject.Web.Mvc

How to Inject EF Core in MVC .Net Framework 4.6.1

THammond9 opened this issue · 0 comments

I am having trouble injecting EF Core into my MVC Web application (framework 4.6.1). I have a SO question here but to summerize:
I am binding the DbContext to itself in transient scope but it seems that the context instance is being reused and then it fails because EF has closed the connections. In the controller method I make a call to the db in one repository which works and then I make a call to the db in a different repository which fails and throws an exception.

No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.

Code examples are in the SO question.