Rollback EF6 Transaction
We are extending the context object to have synchronization functionality with another system. We are currently doing this in savechanges. However, we realized that there is a case where the context would be used in a transaction state, using begintransaction with multiple calls to persist the changes. We don't want to sync the data until the full process is complete. We thought about doing this to get rid of the context.
The only problem we have is knowing if the transaction is successful. If that succeeds, then great sync. If it rolled back, then we certainly don't want to sync. How do we know the state of a transaction when the context is deleted?
source to share
Ask for your models that require synchronization to implement the iSyncable interface, for example promises, which you will synchronize once the model is successfully saved. If you have linked tables via navigation properties, save everything and put them in navigation properties before synchronizing them so that your sync function has all the objects it needs.
By the way, if you need to do any data transformations, this will be where you do it.
source to share