Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Inject EF Core in MVC .Net Framework 4.6.1 #49

Open
THammond9 opened this issue Aug 31, 2018 · 0 comments
Open

How to Inject EF Core in MVC .Net Framework 4.6.1 #49

THammond9 opened this issue Aug 31, 2018 · 0 comments

Comments

@THammond9
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant