Jul 21, 2012 at 6:17 PM


I have a question about transaction management.

What is the best way to do transactional operation on business layer through more than one entitiy object?

Suppose i have Customer and Address objects. First i want to insert the customer and then the address. if address insert fails i want to rollback the customer insert.

I don't really want to use TransactionScope object.



Jul 21, 2012 at 6:41 PM

Why don't you want to use the TransactionScope class? Any special reason?

Jul 21, 2012 at 8:07 PM

I read that it is slower, it takes more time to commit comparing with the old fashion transaction.

Jul 21, 2012 at 9:41 PM

If you are using a transaction against a single database with a single connection string, TransactionScope uses so called Lightweight transaction manager which is more or less equivalent to using plain ADO.NET transactions with no significat performance penalty (think of it as an "ambient" ITransaction object which all methods running under a TransactionScope can use).

Only if your transaction spans more databases or even a non-relational data store, then the rather heavy MS DTC kicks in with the 2 phase commit protocol but this is inevitable also if you wouldn't use TranscationScopes.

Jul 21, 2012 at 9:42 PM

Also read for more information when a TransactionSope is promoted from lightweight to distributed.

Jul 23, 2012 at 2:12 PM

Thank you very much.

After your response i wrote simple application in c# with native sql client and saw that it doesnt need DTC.

My start point was to use TransactionScope together with enterprise library. However, each time I tried to execute sql statement I was receiving DTC service enable error.

So I asked more meaninful :) question on enterprise library discussion board.

Here is the link

I will appreciate if you could answer my question.

Thank you again.

Jul 24, 2012 at 1:08 AM


You can safely use TransactionScope in your business layer and also with Enterprise Library. The tool already provides the generated code for it. To allow TransactionScope to work you need to ensure the following services are running:

  • KtmRm for Distributed Transaction Coordinator
  • Distributed Transaction Coordinator

All Transaction-based processing will always be slower than non transaction-based, however, it is not to a point where it is unusable or bad. For data insertions/modifications protected by TransactionScope, it is surely justified. Do take note not to use any form of Transactions in query operations.


Jul 24, 2012 at 7:45 PM

Thank you very much,