Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos tests sometimes run out of internal service providers #32647

Closed
ajcvickers opened this issue Dec 19, 2023 · 1 comment
Closed

Cosmos tests sometimes run out of internal service providers #32647

ajcvickers opened this issue Dec 19, 2023 · 1 comment
Labels
area-cosmos area-test closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Member

 Microsoft.EntityFrameworkCore.MaterializationInterceptionCosmosTest.Intercept_query_materialization_for_full_constructor(inject: False)
System.InvalidOperationException : An error was generated for warning 'Microsoft.EntityFrameworkCore.Infrastructure.ManyServiceProvidersCreatedWarning': More than twenty 'IServiceProvider' instances have been created for internal use by Entity Framework. This is commonly caused by injection of a new singleton service instance into every DbContext instance. For example, calling 'UseLoggerFactory' passing in a new instance each time--see https://go.microsoft.com/fwlink/?linkid=869049 for more details. This may lead to performance issues, consider reviewing calls on 'DbContextOptionsBuilder' that may require new service providers to be built. This exception can be suppressed or logged by passing event ID 'CoreEventId.ManyServiceProvidersCreatedWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
   at Microsoft.EntityFrameworkCore.Diagnostics.EventDefinition.Log[TLoggerCategory](IDiagnosticsLogger`1 logger, Exception exception) in C:\local\code\efcore\src\EFCore\Diagnostics\EventDefinition.cs:line 68
   at Microsoft.EntityFrameworkCore.Diagnostics.CoreLoggerExtensions.ManyServiceProvidersCreatedWarning(IDiagnosticsLogger`1 diagnostics, ICollection`1 serviceProviders) in C:\local\code\efcore\src\EFCore\Diagnostics\CoreLoggerExtensions.cs:line 962
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<GetOrAdd>g__BuildServiceProvider|4_1(IDbContextOptions _, ValueTuple`2 arguments) in C:\local\code\efcore\src\EFCore\Internal\ServiceProviderCache.cs:line 155
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c.<GetOrAdd>b__4_0(IDbContextOptions contextOptions, ValueTuple`2 tuples) in C:\local\code\efcore\src\EFCore\Internal\ServiceProviderCache.cs:line 70
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired) in C:\local\code\efcore\src\EFCore\Internal\ServiceProviderCache.cs:line 68
   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options) in C:\local\code\efcore\src\EFCore\DbContext.cs:line 128
   at Microsoft.EntityFrameworkCore.TestUtilities.PoolableDbContext..ctor(DbContextOptions options) in C:\local\code\efcore\test\EFCore.Specification.Tests\TestUtilities\PoolableDbContext.cs:line 14
   at Microsoft.EntityFrameworkCore.SingletonInterceptorsTestBase`1.LibraryContext..ctor(DbContextOptions options) in C:\local\code\efcore\test\EFCore.Specification.Tests\SingletonInterceptorsTestBase.cs:line 74
   at Microsoft.EntityFrameworkCore.MaterializationInterceptionCosmosTest.CosmosLibraryContext..ctor(DbContextOptions options) in C:\local\code\efcore\test\EFCore.Cosmos.FunctionalTests\MaterializationInterceptionCosmosTest.cs:line 21
   at Microsoft.EntityFrameworkCore.MaterializationInterceptionCosmosTest.CreateContext(IEnumerable`1 interceptors, Boolean inject) in C:\local\code\efcore\test\EFCore.Cosmos.FunctionalTests\MaterializationInterceptionCosmosTest.cs:line 34
   at Microsoft.EntityFrameworkCore.MaterializationInterceptionTestBase`1.Intercept_query_materialization_for_full_constructor(Boolean inject) in C:\local\code\efcore\test\EFCore.Specification.Tests\MaterializationInterceptionTestBase.cs:line 427
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

@ajcvickers
Copy link
Member Author

Fixed by @AndriySvyryd

@ajcvickers ajcvickers added type-bug area-test closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Jan 10, 2024
@ajcvickers ajcvickers added this to the 9.0.0 milestone Jan 10, 2024
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-preview1 Jan 31, 2024
@roji roji modified the milestones: 9.0.0-preview1, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cosmos area-test closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

2 participants