撤回 dbcontext 连接池
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-02 17:44:45 +08:00
parent c353ae645b
commit 4eaf070243
3 changed files with 12 additions and 11 deletions
@@ -26,7 +26,7 @@ namespace IRaCIS.Core.API
//这个注入没有成功--注入是没问题的,构造函数也只是支持参数就好,错在注入的地方不能写DbContext
//Web程序中通过重用池中DbContext实例可提高高并发场景下的吞吐量, 这在概念上类似于ADO.NET Provider原生的连接池操作方式,具有节省DbContext实例化成本的优点
services.AddPooledDbContextFactory<IRaCISDBContext>(options =>
services.AddDbContext<IRaCISDBContext>(options =>
{
// 在控制台
@@ -80,10 +80,10 @@ namespace IRaCIS.Core.API
});
// Register an additional context factory as a Scoped service, which gets a pooled context from the Singleton factory we registered above,
services.AddScoped<IRaCISDBScopedFactory>();
//services.AddScoped<IRaCISDBScopedFactory>();
// Finally, arrange for a context to get injected from our Scoped factory:
services.AddScoped(sp => sp.GetRequiredService<IRaCISDBScopedFactory>().CreateDbContext());
//// Finally, arrange for a context to get injected from our Scoped factory:
//services.AddScoped(sp => sp.GetRequiredService<IRaCISDBScopedFactory>().CreateDbContext());
//注意区分 easy caching 也有 IDistributedLockProvider
services.AddSingleton<IDistributedLockProvider>(sp =>