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

Soft Delete #4025

Open
Tracked by #22954 ...
ghost opened this issue Dec 9, 2015 · 13 comments
Open
Tracked by #22954 ...

Soft Delete #4025

ghost opened this issue Dec 9, 2015 · 13 comments

Comments

@ghost
Copy link

ghost commented Dec 9, 2015

Hello.

Any suggestions on how to implement a soft delete at Entity Framework 7 ?

Any help is much appreciated.

Regards.

@rowanmiller rowanmiller added this to the Backlog milestone Dec 22, 2015
@rowanmiller
Copy link
Contributor

We're putting this one on the backlog as a feature we would like to have at some point.

In the meantime, you probably could do this by overriding some of the low level components... but that is going to be fairly complex to do. If you decide to try... then you will probably make things less painful if you have your soft delete flag mapped as a shadow state property. For SaveChanges, you could look at a custom implementation of ICommandBatchPreparer.BatchCommands to generate updates rather than deletes for state entries that are marked as deleted.

cc @anpete in case he can give you a pointer of where to look for query.

@anpete
Copy link
Contributor

anpete commented May 8, 2017

Enabled in b1379b1

@seriouz
Copy link

seriouz commented May 9, 2017

I think we definitely need an opt-out operator like: .NotFiltered()

@smitpatel
Copy link
Member

@smitpatel smitpatel removed this from the Backlog milestone May 9, 2017
@smitpatel
Copy link
Member

@anpete - Is this issue fully resolved? If yes then we should close the issue and set the milestone.

cc: @divega

@anpete
Copy link
Contributor

anpete commented May 9, 2017

Unless we want to track a specific high-level Soft Delete feature.

@ajcvickers
Copy link
Member

I think we do want to track that feature. Specifically, I should be able to delete objects normally in my graph or with .Remove, and then have it automatically soft delete those entities.

@divega
Copy link
Contributor

divega commented May 9, 2017

Agreed. Query filters only solves a part of what we need.

@ajcvickers
Copy link
Member

Note to implementer: remember to make cascade delete (of tracked entities) work.

@Geestarraw

This comment was marked as resolved.

@roji

This comment was marked as resolved.

@qsdfplkj
Copy link

To me soft deletes don't make sense. On a database level: Any unique constraint will break. What about a foreign key that has been soft deleted? Do we need cascading soft deletes? You could build an entire shadow database with soft deleted entities. To me soft deletes should be related to business logic, e.g. add an start and end date to a subscription. Soft delete will only work on database that do not have any constraints but then the problem is just moved to the point of where we need to read the data.

Maybe temporal tables can be used for soft deletes.

@seriouz
Copy link

seriouz commented Oct 21, 2023

Yes soft deletes should respect cascade delete. Sure you can implement it easy by youself with thousands of possibilities. But i imagine an EF Core Soft Delete like a ready-to-go solution - where i (as a dev) have not to know how its working behind the scenes and i don't have to touch the queries (apart from when i must read/recover deleted data).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants