From d4c68b9d10c22a55c63c5252fbfbc2ac16c0f483 Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Mon, 29 Jan 2024 17:19:23 +0330 Subject: [PATCH] Fix Scope DI --- .../StartUpExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs index 3778a40..1bce7ad 100644 --- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs +++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs @@ -81,11 +81,12 @@ public static IServiceCollection Builder(this IServiceCollection servi }); services.AddScoped(service => new UnitOfWork(service).GetMapper()); services.AddTransient(serviceProvider => serviceProvider.GetService()); + services.AddTransient(serviceProvider => serviceProvider.GetService()); services.AddExceptionHandler((option) => { option.ExceptionHandler = AppAuthorizationMiddleware.ExceptionHandler; }); - services.AddSingleton(service => new Contents.GeneratedServices.ContentClient(GetContentAddress(service)?.Address, new HttpClient())); + services.AddScoped(service => new Contents.GeneratedServices.ContentClient(GetContentAddress(service)?.Address, new HttpClient())); services.AddSingleton(); services.AddSingleton(); return services;