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

Connection Leak with ASP.NET Core DI #159

Open
ConX-Ryan opened this issue Sep 14, 2017 · 1 comment
Open

Connection Leak with ASP.NET Core DI #159

ConX-Ryan opened this issue Sep 14, 2017 · 1 comment

Comments

@ConX-Ryan
Copy link

ConX-Ryan commented Sep 14, 2017

services.AddTransient<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<DbShardContextFactory>();

 services.AddScoped<ConXDbContext<Guid>>(provider => 
                 provider.GetService<DbShardContextFactory>().CreateShardContext());

 services.AddIdentity<AppUser, IdentityRole>()
                .AddEntityFrameworkStores<ConXDbContext<Guid>>()
                .AddDefaultTokenProviders();

I am using a single tenant config where i need to route to a customer shard based on the request. The DbShardContextFactory does this with help from the HttpContextAccessor.

Because the factory creates the DbContext instead of the DI Container it appears to not be disposing correctly even though defined as Scoped. so the .AddEntityFrameworkStores<ConXDbContext<Guid>>()
call i believe is the issue

What is the correct pattern here to use the standard ASP.NET Core service collection?

@chsakell
Copy link

chsakell commented Oct 6, 2017

@ConX-Ryan have you managed to use the library with .net core 2.0 ? Any sample available? As of 118 is not supported yet. Any help would be appreciated.

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

2 participants