Skip to content

Commit 4682a72

Browse files
renemadsenclaude
andcommitted
perf(db): pool BaseDbContext registrations in Startup
Swap AddDbContext<BaseDbContext> to AddDbContextPool<BaseDbContext> in all three mutually-exclusive host registration branches (primary connection, fallback connection, localhost placeholder). Pool size is left at the default (1024). BaseDbContext has a DbContextOptions<BaseDbContext> ctor and no OnConfiguring override, so pooling is semantically equivalent to the current scoped registration from the caller's perspective. This commit has no observable effect on its own because three plugins (Workflow, TimePlanning, BackendConfiguration) still re-register BaseDbContext via plain AddDbContext, and DI resolves last-wins. Those re-registrations are removed in the next commit to actually engage pooling. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4114330 commit 4682a72

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

eFormAPI/eFormAPI.Web/Startup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void ConfigureServices(IServiceCollection services)
107107
{
108108
Log.LogEvent($"We do have a ConnectionString {Configuration["ConnectionString"]}");
109109
services.AddEntityFrameworkMySql()
110-
.AddDbContext<BaseDbContext>(o => o.UseMySql(
110+
.AddDbContextPool<BaseDbContext>(o => o.UseMySql(
111111
Configuration["ConnectionString"], new MariaDbServerVersion(
112112
ServerVersion.AutoDetect(Configuration["ConnectinString"])), mySqlOptionsAction: builder =>
113113
{
@@ -159,7 +159,7 @@ public void ConfigureServices(IServiceCollection services)
159159
{
160160
Log.LogEvent($"ConnectionString is {Configuration.MyConnectionString()}");
161161
services.AddEntityFrameworkMySql()
162-
.AddDbContext<BaseDbContext>(o => o.UseMySql(
162+
.AddDbContextPool<BaseDbContext>(o => o.UseMySql(
163163
Configuration.MyConnectionString(), new MariaDbServerVersion(
164164
ServerVersion.AutoDetect(Configuration.MyConnectionString())), mySqlOptionsAction: builder =>
165165
{
@@ -208,7 +208,7 @@ public void ConfigureServices(IServiceCollection services)
208208
// We use this hack to get the project started and we actually don't use this connection, but it's needed for the service to start.
209209
// Once we have the correct connectionstring in the connection.json, we restart the server and the above method is used.
210210
services.AddEntityFrameworkMySql()
211-
.AddDbContext<BaseDbContext>(o => o.UseMySql(
211+
.AddDbContextPool<BaseDbContext>(o => o.UseMySql(
212212
"server=localhost;", new MariaDbServerVersion(
213213
new Version(10, 4, 0)), mySqlOptionsAction: builder =>
214214
{

0 commit comments

Comments
 (0)