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

Expose IDbConnection through DI #2757

Closed
mdockal opened this issue Nov 28, 2018 · 1 comment · Fixed by #2761
Closed

Expose IDbConnection through DI #2757

mdockal opened this issue Nov 28, 2018 · 1 comment · Fixed by #2761
Milestone

Comments

@mdockal
Copy link
Contributor

mdockal commented Nov 28, 2018

I tried to access the DBConnection directly in a module so I can use dapper.contrib to add custom tables in my module. I added the following code in Startup.cs

 public override void Configure(IApplicationBuilder builder, IRouteBuilder routes, IServiceProvider serviceProvider)
{
     var connection = serviceProvider.GetRequiredService<IDbConnection>();
     //var connection = serviceProvider.GetService<IDbConnection>();
}

Got the following exception:
InvalidOperationException: No service for type 'System.Data.IDbConnection' has been registered.

I think this would also resolve #2248

@infofromca
Copy link
Contributor

#1401

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

Successfully merging a pull request may close this issue.

3 participants