-
Notifications
You must be signed in to change notification settings - Fork 47
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
EF.Triggers and .Net Core transactions #49
Comments
Hi @chicobaptista , Hi @chicobaptista , This is an interesting use case. I hadn't come up with a good design for handling transactions so I just left it. Could you create a transaction for the other context and roll it back if the first one throws? |
Hey @NickStrupat, we don't actually have different db contexts, but multiple We came up with another idea today, to use the |
So the transaction isn't applied to all the changes within that single instance of DbContext? |
Hello I've a question about using your EF.Triggers library together with Transactions and transactions scopes.
We're using transactions when modifying several database entries, so that if one operation fails/ is rejected, the whole transaction rolls back. However, since there are multiple
context.SaveChanges()
calls inside the transactions, theTriggers.Updated
and.TriggersInserted
triggers are activated, and if the transaction is rolled back, I have not found a way to revert the changes made by the handlers when the triggers are activated. I am mostly using the library to send the database changes to a realtime subset database, and this library would be a nice way to keep this second db in sync.Reading other issues (specifically #20 (comment)_) and questions on SO and googling, I found some references that
Triggers.Updated
orTriggers.Created
should be used only when you know that the data has been persisted.Is there a trigger that gets activated on rollback (
Triggers.UpdateFailed
and such don't appear to behave this way) or any other suggestion on how to handle this situation? One of our options includes rewriting the whole transactions logic to make just onecontext.SaveChanges()
call per transaction, accumulating all EF changes in one batch, but that would have other implications to our architecture and frankly would mean a lot of rewriting, so if possible I would like to avoid that as much as possible.The text was updated successfully, but these errors were encountered: