Skip to content

Instantly share code, notes, and snippets.

@mirmostafa
Created August 30, 2021 15:35
Show Gist options
  • Save mirmostafa/5bd23b63b0fc35e2310994c14283ded2 to your computer and use it in GitHub Desktop.
Save mirmostafa/5bd23b63b0fc35e2310994c14283ded2 to your computer and use it in GitHub Desktop.
DbContext Pool Service
public void ConfigureServices(IServiceCollection services)
{
//....
services.AddDbContextPool<S2ReadDbContext>(options =>
{
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
options.UseSqlServer(Configuration.GetConnectionString("S2ReadConnection"));
options.EnableSensitiveDataLogging();
});
services.AddDbContextPool<S2WriteDbContext>(options =>
{
options.UseQueryTrackingBehavior(QueryTrackingBehavior.TrackAll);
options.UseSqlServer(Configuration.GetConnectionString("S2WriteConnection"));
options.EnableSensitiveDataLogging();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment