From a71716640226f00598fb1e706b75b15764f01578 Mon Sep 17 00:00:00 2001 From: Bervianto Leo Pratama Date: Fri, 24 Apr 2026 09:54:27 +0700 Subject: [PATCH] Implement environment-based logic in AddServiceDefaults Add conditional check for environment and command line arguments in AddServiceDefaults method. --- .../Extensions.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BervProject.WebApi.Boilerplate.ServiceDefaults/Extensions.cs b/BervProject.WebApi.Boilerplate.ServiceDefaults/Extensions.cs index 5d5b8720..58c936f0 100644 --- a/BervProject.WebApi.Boilerplate.ServiceDefaults/Extensions.cs +++ b/BervProject.WebApi.Boilerplate.ServiceDefaults/Extensions.cs @@ -16,6 +16,13 @@ public static class Extensions { public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) { + if (builder.Environment.EnvironmentName == "Development" && + (System.Environment.GetCommandLineArgs().Any(arg => arg.Contains("ef")) || + System.Environment.GetCommandLineArgs().Any(arg => arg.Contains("database")))) + { + return builder; + } + builder.ConfigureOpenTelemetry(); builder.AddDefaultHealthChecks();