diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs index b5ce25aa82..7907acc67b 100644 --- a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs +++ b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs @@ -24,6 +24,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; namespace JsonApiDotNetCore.Configuration @@ -212,7 +213,7 @@ private void RegisterImplementationForOpenInterfaces(HashSet openGenericIn { Type implementationType = openGenericInterface.GetGenericArguments().Length == 1 ? intImplementation : implementation; - _services.AddScoped(openGenericInterface, implementationType); + _services.TryAddScoped(openGenericInterface, implementationType); } }