Post-move Exception: "Cannot create a command without an existing connection"

Description:

We've identified an issue in Optimizely CMS’s internal handling of content moves using _contentRepository.Move(...), specifically when moving content to the recycle bin (ContentReference.WasteBasket) from a background service or scheduled job.

The content is successfully moved, but immediately after, an exception is thrown:

System.InvalidOperationException: Cannot create a command without an existing connection, you can use DbFactory to create stand-alone command objects

This suggests that some internal follow-up operation—likely a cache update, event propagation, or DB trigger—attempts to create a database command without a valid connection, possibly due to the move being triggered outside of an HTTP request context.

This issue appears to originate from Optimizely CMS internals and not from custom logic.

Stack Trace:

at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.ExecuteTransaction(Action action)  
at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method)  
at EPiServer.DataAccess.Internal.ContentSaveDB.Move(Int32 contentLinkID, Int32 destinationLinkID, Boolean archive)  
at EPiServer.Core.Internal.DefaultContentProviderDatabase.Move(...)  
at EPiServer.Core.Internal.DefaultContentProvider.Move(...)  
at EPiServer.Core.Internal.DefaultContentRepository.Move(...)

Environment details:

  • Optimizely CMS version: 12.33.1

  • EPiServer.CMS.Core version: 12.22.7

  • .NET version: .NET 8

  • Hosted on: Azure

Please let us know if this is a known issue, or if there’s a recommended workaround for safely moving content from background services without triggering this exception.

#339685
Jul 15, 2025 10:55

This doesn't look right.

I bet the product team would appreciate it if you submit your findings on support.optimizely.com.

#339746
Jul 17, 2025 16:10
velijaa - Aug 22, 2025 15:26
Thanks for your reply! I’ve already submitted the findings on support.optimizely.com for the product team. Let’s wait and see how it plays out.

Hi,

Did you get a resolution? I'm seeing similar behavior in my own background tasks.

Best regards
F

#341604
Feb 04, 2026 13:28

We are also hitting this issue.  Did anyone get a resolution?

#342992
Jul 09, 2026 22:14

I found CMS-46455 in the EPiServer.CMS.Core 12.22.9 release notes. It addresses background tasks not running in an isolated context, which could cause conflicts with database contexts and parallel tasks.

The original report was using EPiServer.CMS.Core 12.22.7, so that fix was not included in the reported environment.

However, the release note does not specifically mention IContentRepository.Move(), ContentReference.WasteBasket, or the exact “Cannot create a command without an existing connection” exception. Therefore, CMS-46455 should only be considered a potentially related fix, not a confirmed resolution for this issue.

It would be worth upgrading to the latest compatible CMS version and retesting. If the exception remains, the Optimizely support case would be the best source for confirming the exact bug reference and resolution.

Release notes:
https://support.optimizely.com/hc/en-us/articles/42412167768333-2025-Optimizely-CMS-12-release-notes

#343031
Jul 14, 2026 15:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.