EF and TransactionScope for both SQL Server and Oracle without escalating/spanning to DTC? -


can update me on topic?

i want support both sql server , oracle in application.

is possible have following code (in bl) working both sql server , oracle without escalating/spanning distributed transactions (dtc) ?

 // dbcontext created before, same dbcontext used both repositories  using (var ts = new transactionscope())  {     // create order - make use of dbcontext, possibly call savechanges here     orderrepository.createorder(order);      // update inventory - make use of same dbcontext, possibly call savechanges here     inventoryrepository.updateinventory(inventory);      ts.complete();  } 

as of today, end of august 2013, understand works sql server 2008+ ... oracle? found thread... looks oracle promoting distributed transactions still not clear me.

does have experience writing apps support both sql server , oracle entity framework enlighten me?

thanks!

update: noticed ef6 comes improved transaction support. this, in addition remus' recommendations solution me.

first: never use var ts = new transactionscope(). 1 liner kills app. use explicit constructor let specify isolation level. see using new transactionscope() considered harmful.

now question: logic not promote 2 connections in same scope dtc relies heavily on driver/providers cooperating inform system.transactions 2 distinct connections capable of managing distributed transaction fine on own because resource managers involved same. sqlclient post sql server 2008 driver capable of doing logic. oracle driver use not (and i'm not aware of version is, btw).

ultimately really basic: if not want dtc, not create one! make sure use 1 connection in scope. arguable not need 2 connections. in other words, rid of 2 separate repositories in data model. use 1 repository orders, inventory , else not. shooting in foot them , you're asking pixie dust solutions.

update: oracle driver 12c r1:

"transaction , connection association: odp.net connections, default, detach transactions when connection objects closed or transaction objects disposed"


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -