Click here to Skip to main content
15,029,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
My project using WebAPI, EF 6.0 and repository pattern, I wanted to implement Transaction scope in project, I have doubt about which transaction scope to be used
Note : I have only one database

1) .Net (TransactionScope ts=new TransactionScope() )
OR
2) Transaction scope of EF(DbContext.Database.BeginTransaction())

which one is better or which one has advantages?
Posted
Updated 12-Dec-14 3:28am
v2

1 solution

you should go for 2nd option if you only need to handle database transactions.
(note that TransactionScope can make code block to a transnational, so it capable of handling transactions other than databases as well)
refer : Database.BeginTransaction vs Transactions.TransactionScope[^]
update:
======
Quote:
I feel second option is not that easy to implement as I have Repository pattern implemented, First one is easy to implement, Is there benefit of second option or any drawback of first one

check Repository Pattern and Unit of Work with Entity Framework in ASP.NET MVC[^] for sample code
   
v3
Comments
git_mshah 12-Dec-14 9:54am
   
Thanks DamithSL. I have to handle only database transactions. I feel second option is not that easy to implement as I have Repository pattern implemented, First one is easy to implement, Is there benefit of second option or any drawback of first one

Thanks in advance.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900