Skip to content

Fix issue with use of EF Core scopes within notification handlers (take 2 - handling scopes with a base parent)#19797

Merged
Migaroez merged 4 commits intomainfrom
v16/bugfix/efcorescope-locks-with-base-parent
Jul 25, 2025
Merged

Fix issue with use of EF Core scopes within notification handlers (take 2 - handling scopes with a base parent)#19797
Migaroez merged 4 commits intomainfrom
v16/bugfix/efcorescope-locks-with-base-parent

Conversation

@Migaroez
Copy link
Contributor

@Migaroez Migaroez commented Jul 25, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

Fixes #18977

Description

Andy found the troublesome code in #19787 and after putting our heads together we can up with a better solution.

Testing

See manual testing steps in #19787 and the included integration tests

Todo after merge

  • cherry pick to 13
  • cherry pick to 15

@Migaroez Migaroez requested review from AndyButland and Zeegaan July 25, 2025 08:46
@AndyButland AndyButland changed the title V16/bugfix/efcorescope locks with base parent Fix issue with use of EF Core scopes within notification handlers (take 2 - handling scopes with a base parent) Jul 25, 2025
Moved tests alongside existing ones related to scopes.
Removed long running attribute from tests (they are quite fast).
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I made a few minor tweaks so please check you are happy with them.

I've verified by porting this fix back to 13 that it resolves the original issue that was raised, so once we cherry-pick this back there we can close that issue.

@Migaroez Migaroez merged commit a2cc6a0 into main Jul 25, 2025
24 of 25 checks passed
@Migaroez Migaroez deleted the v16/bugfix/efcorescope-locks-with-base-parent branch July 25, 2025 11:07
Migaroez added a commit that referenced this pull request Jul 25, 2025
…ke 2 - handling scopes with a base parent) (#19797)

* Add integration tests that shows the problem

* Fix the problem and add explenation

* Improved comments slightly to help when we come back here!
Moved tests alongside existing ones related to scopes.
Removed long running attribute from tests (they are quite fast).

* Fixed casing in comment.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
Migaroez added a commit that referenced this pull request Jul 25, 2025
…ke 2 - handling scopes with a base parent) (#19797)

* Add integration tests that shows the problem

* Fix the problem and add explenation

* Improved comments slightly to help when we come back here!
Moved tests alongside existing ones related to scopes.
Removed long running attribute from tests (they are quite fast).

* Fixed casing in comment.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Scope being disposed is not the Ambient Scope when using EF Core in notification handler

2 participants