Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the entity framework to work with archive flags?

I'm trying to create a set of tables where we don't actually delete them, but rather we set the archive flags instead. When we delete an entity, it shouldn't be deleted, it should be marked as archived instead.

What are the programming patterns to support this?

I would also prefer not to have to roll out my own stored procs for every table that have these archive flags if there is another solution.

like image 539
Orion Adrian Avatar asked Nov 05 '22 14:11

Orion Adrian


1 Answers

This is an old question and it doesn't specify the EntityFramework version. There are a few good solution for newer versions:

Entity Framework: Soft Deletes Are Easy

Soft Delete pattern for Entity Framework Code First

Entity Framework 5 Soft Delete

Also there are sources for EF 6.1.1+

Highlights of Rowan Miller’s EF6/EF7 Talk at TechEd 2014

Entity Framework: Building Applications with Entity Framework 6

like image 140
Adam Ocsvari Avatar answered Nov 12 '22 12:11

Adam Ocsvari