C# – System.Transactions.TransactionScope

TransactionScope is not only for the databases. Every component that implements IEnlistmentNotification interface can participate in two-phase commit of the transaction scope. Here is an example of transactional in-memory storage: http://www.codeproject.com/KB/dotnet/Transactional_Repository.aspx Also, I’m not sure if there are components in .NET for transactional file IO, but it is pretty easy to implement such component – … Read more

“The operation is not valid for the state of the transaction” error and transaction scope

After doing some research, it seems I cannot have two connections opened to the same database with the TransactionScope block. I needed to modify my code to look like this: public void MyAddUpdateMethod() { using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { using(SQLServer Sql = new SQLServer(this.m_connstring)) { //do my first add update statement } //removed … Read more

Database.BeginTransaction vs Transactions.TransactionScope [duplicate]

I found out the answer in Entity Framework 6’s documentation: With the introduction of EF6, Microsoft recommends to use new API methods: Database.BeginTransaction() and Database.UseTransaction(). Although System.Transactions.TransactionScope is still very well supported, it is no longer necessary for most users of EF6. While Database.BeginTransaction() is used only for database related operations transaction, System.Transactions.TransactionScope, in addition … Read more

Why is System.Transactions TransactionScope default Isolationlevel Serializable

The fact Serializable is the default comes from times when .NET wasn’t even released (before year 1999), from DTC (Distributed Transaction Coordinator) programming. DTC uses a native ISOLATIONLEVEL enumeration: ISOLATIONLEVEL_SERIALIZABLE Data read by a current transaction cannot be changed by another transaction until the current transaction finishes. No new data can be inserted that would … Read more

The transaction manager has disabled its support for remote/network transactions

Make sure that the “Distributed Transaction Coordinator” Service is running on both database and client. Also make sure you check “Network DTC Access”, “Allow Remote Client”, “Allow Inbound/Outbound” and “Enable TIP”. To enable Network DTC Access for MS DTC transactions Open the Component Services snap-in. To open Component Services, click Start. In the search box, … Read more