How can I get Entity Framework and WCF to work with transactions? Okay ... what's the secret?

I tried several different ways to get a simple set of transactions to work in a simple WCF client / server situation. My WCF server has a class declaration of an Entity Framework class class for my access to the database and several methods for modifying data and the SaveChanges method. I am using Oracle Data Access (ODP.NET).

For example, I want to call a modification from the client, and then a separate call to save the changes to the WCF service. This does not work. In principle, everything runs fine, but when the second call is made to save the changes, the WCF service no longer has the original context, and therefore no changes are saved (and, therefore, the previous call, as a result of which the changes were automatically rolled back).

I use the transaction scope for both operations in my client and doing Complete () after completion. My WCF services have an OperationContract that they use [TransactionFlow(TransactionFlowOption.Mandatory)], and these method implementations use [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]. Finally, my web configuration is configured using wsHttpBinding, which has the property transactionFlowset to True.

I was not lucky. No matter what I try, when I try to use the service for later save, the EF context is already updated.

+5
source share
2 answers

. , SaveChanges , EF - SaveChanges. . EF . , = EF, .

. . WCF, . , .

+4

. . , , , , , savechnages(). ,

+1

All Articles