If you are calling SaveChanges()
multiple times, and want to roll back all of those changes, yes you would want to use a TransactionScope
. If you are calling SaveChanges()
once on the context, all your changes are pushed to the database at once in a transaction behind the scenes.
Does EF5 DbContext.SaveChanges handle transaction commit and rollback?
-
01-06-2022 - |
Question
I am not clear on whether I need to use TransactionScope or DbContext.SaveChanges() is enough to commit my transaction consisting of multiple CRUD operations. I am using SQL Server in the backend.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow