oqtane / oqtane.framework

CMS & Application Framework for Blazor & .NET MAUI
http://www.oqtane.org
MIT License
1.9k stars 550 forks source link

Hard deletion of page more robust use of entity framework contexts #4705

Closed maurocavallin closed 1 month ago

maurocavallin commented 1 month ago

The issue:

Step to Reproduce:

Spot the issue: All seems to go well on UI but looking at the record in the db I see a stale record of that page still present (module and permission are correctly deleted, but not the record in the page db table).

Since the page on db has no permission linked to it I won't see that page anywhere in the UI. But it will remain in database forever.

This happens in SqlServer and SqlLite (an i guess in any other db, its an entity framework context thing).

The problem is the use of multiple opened ef context in deletion of module of the page (one ef dbcontext) and the page itself (another ef dbcontext): the fix in code is self-explanatory.

maurocavallin commented 1 month ago

@dotnet-policy-service agree

sbwalker commented 1 month ago

@maurocavallin thank you for the detailed explanation of the problem