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

Handling deleted and updated entities in the same saveChanges call when cascade delete is configure in the db #62

Open
graphicsxp opened this issue Oct 26, 2021 · 1 comment

Comments

@graphicsxp
Copy link

graphicsxp commented Oct 26, 2021

I'm facing an issue when saving parent and child entities at the same time :

Let's say I have the following entities:

Publication { id: guid; publicationLvs: PublicationLv [ ] }
PublicationLv { id: guid; publicationId: guid }

I delete the parent entity :

publication.entityAspect.setDeleted();

Then when I call save changes, the payload looks like this :
image

So Publication is deleted and PublicationLv is modified with its foreign key PublicationId set to a 0 guid.

When saveChanges is called on the server (Entity Framework Core), I get a 500 :

image

It seems breeze doesn't know about the cascade delete configured in the DB. So when it tries to update publicationLv, it was already deleted when the Publication was deleted.

Is this a configuration issue or a bug ? Here's my metadata :

image

image

@graphicsxp graphicsxp changed the title Handling deleted and updated entities in the same saveChanges call Handling deleted and updated entities in the same saveChanges call when cascade delete is configure in the db Oct 26, 2021
@graphicsxp
Copy link
Author

I detach all the children entities before deleting the Publication. It works fine. But this Stackoverflow answer suggests that this would have been implemented in breeze at some point (7 years ago). Is it the case ?
https://stackoverflow.com/questions/26724082/cascade-delete-not-working-with-breeze

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

No branches or pull requests

1 participant