I do have a ASP.NET Core 2.0 application with Microsoft.Extensions.DependencyInjection.
I added my Context ApplicationDbContext to the Startup.cs file:
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(DefaultConnection));
My ApplicationDbContext inherits the DbContext class:
In a generic controller I require a DbContext class:
public GenericController(DbContext context){
However Microsoft.Extensions.DependencyInjection cannot resolve the DbContext to the ApplicationDbContext registered service.
How can I inject the required DbContext class into my service class?
I'm able to change the GenericController, but the project where GenericController lies does not have reference to the ApplicationDbContext.
I'm developing a middleware, it should require DbContext that should be specialized in other projects. So the controller is in the middleware, it does not have a reference to the specialized class.