Skip to content

Commit a717166

Browse files
authored
Implement environment-based logic in AddServiceDefaults
Add conditional check for environment and command line arguments in AddServiceDefaults method.
1 parent 1543239 commit a717166

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

BervProject.WebApi.Boilerplate.ServiceDefaults/Extensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public static class Extensions
1616
{
1717
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
1818
{
19+
if (builder.Environment.EnvironmentName == "Development" &&
20+
(System.Environment.GetCommandLineArgs().Any(arg => arg.Contains("ef")) ||
21+
System.Environment.GetCommandLineArgs().Any(arg => arg.Contains("database"))))
22+
{
23+
return builder;
24+
}
25+
1926
builder.ConfigureOpenTelemetry();
2027

2128
builder.AddDefaultHealthChecks();

0 commit comments

Comments
 (0)