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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top