We have a data model that has some requirements. I would like to find a way to make these requirements be as transparent as possible while using EF.
First, the model must support soft-delete. I've seen some questions around this and I think it would be relatively straight forward.
Second, We have an "insert only" policy. That means no updates. When an update is made, a new entry must be inserted instead. I would like to be able to treat the operation as an update, and have the framework change it to an insert behind the scenes.
Third, Due to #2 when we query, we need to order by descending on the identity column and return the first record only. Even when doing a query that returns many records. Essentially, this creates a version history.
Fourth, we don't want to have to implement this logic in each query. It would be nice to have the framework do it for us so we can treat each query as if it were a normal CRUD type transaction.
Has anyone implemented such a data model in EF? What techniques did you use?
I'm aware that some of this can be done in Views and/or Sprocs, but if you use views then you have to maintain all relationships manually (EF can't read the relationships through the views). Triggers are also a possibility, but our DBA's want as few triggers as possible, and have a very extensive review policy on all triggers that takes a long time to accomplish. I'd rather not use a trigger if I don't have to.
I work primarily in a database first approach, but i use dbcontext.
EDIT:
Given Ladislav's comments below, I'd also be interested in any comments about other ORM's that may be able to handle these requirements.