When using IContentRepository in a service injected by th constructor (Depencency injection).
Our service is registrated as Transient.
When calling:
_contentRepository.GetReferencesToContent(content.ContentLink, includeDecendents);
Sometimes we get the following stacktrace:
System.AggregateException: One or more errors occurred. (Call on database executor not created on current context and on different thread. Possible rooted IDatabaseExecutor, which is not thread safe.)
---> System.InvalidOperationException: Call on database executor not created on current context and on different thread. Possible rooted IDatabaseExecutor, which is not thread safe.
at EPiServer.Data.Internal.ConnectionScopeResolver.AssertThreadSafe()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.CreateCommand()
at EPiServer.DataAccess.Internal.ContentSaveDB.<>c__DisplayClass20_0.<GetReferenceInformationForContent>b__0()
at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass24_0`1.<Execute>b__0()
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)
at EPiServer.DataAccess.Internal.ContentSaveDB.GetReferenceInformationForContent(ContentReference contentLink, Boolean includeDecendents)
at EPiServer.Core.Internal.DefaultContentProvider.GetReferencesToLocalContent(ContentReference contentLink, Boolean includeDecendents)
at EPiServer.Core.Internal.DefaultContentRepository.GetReferencesToContent(ContentReference contentLink, IEnumerable`1 descendents, Boolean includeDescendants)
Is it intended by design that the DbContext inside IContentRepository should not be thread-safe?
Version: 12.4.1
.Net 6.0