For EF 3.5 you don't really have an option, other than sprocs.
But for EF 4.0 we have added a new method to the ObjectContext
called ExecuteStoreCommand(..)
and related methods etc.
So you could override SaveChanges()
, it is now virtual, and interograte the ObjectStateManager
looking for ObjectStateEntries
for the type(s) you are interested in, that are in the EntityState you are interested in (i.e. Inserted) etc.
Once found you could then Execute commands directly against the database using the new ExecuteStoreCommand()
method. Then by calling AcceptChanges()
on the ObjectStateEntry
you stop the EF from trying to flush changes to the database that you have already handled.
Then you can let the EF do the rest of the changes for you by calling base.SaveChanges()
.
I know this is not ideal. But it is the best workaround that I can think of
Alex