diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs index ccf93b0..9bf079a 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs @@ -16,6 +16,7 @@ using System.Linq; using System.Net; using System.Net.Mime; +using System.Text; using System.Text.Json; using System.Threading.Tasks; @@ -109,8 +110,11 @@ public static async Task Build(this IApplicationBuilder app) var dbbuilder = new DatabaseCreator(); using var context = scope.ServiceProvider.GetRequiredService(); dbbuilder.Initialize(context); - using var uow = scope.ServiceProvider.GetRequiredService() as UnitOfWork; - await uow.Initialize(MicroserviceName, config.GetValue(ConfigName), typeof(TContext)).ConfigureAwait(false); + if (WhiteLabelRoute.HasValue() || ConfigName.HasValue()) + { + using var uow = scope.ServiceProvider.GetRequiredService() as UnitOfWork; + await uow.Initialize(MicroserviceName, config.GetValue(ConfigName), typeof(TContext)).ConfigureAwait(false); + } } var build = app.Build(); app.Run(build); @@ -179,7 +183,11 @@ public static async Task Build(this WebApplicationBuil using var context = scope.ServiceProvider.GetRequiredService(); dbbuilder.Initialize(context); using var uow = scope.ServiceProvider.GetRequiredService() as UnitOfWork; - await uow.Initialize(MicroserviceName, WhiteLabelRoute ?? config.GetValue(ConfigName), typeof(TContext)).ConfigureAwait(false); + if (WhiteLabelRoute.HasValue() || ConfigName.HasValue()) + { + var value = WhiteLabelRoute ?? config.GetValue(ConfigName); + await uow.Initialize(MicroserviceName, WhiteLabelRoute ?? config.GetValue(ConfigName), typeof(TContext)).ConfigureAwait(false); + } } return build; }