sql server - The underlying provider failed on Open? -


i created application using entity framework 6 sql. working fine. yesterday got error twice entity framework shown below, after issue not raised yet now.

system.data.entity.core.entityexception: underlying provider failed on open. ---> system.transactions.transactionmanagercommunicationexception: network access distributed transaction manager (msdtc) has been disabled. please enable dtc network access in security configuration msdtc using component services administrative tool. ---> system.runtime.interopservices.comexception: transaction manager has disabled support remote/network transactions. (exception hresult: 0x8004d024)    @ system.transactions.oletx.idtcproxyshimfactory.receivetransaction(uint32 propgationtokensize, byte[] propgationtoken, intptr managedidentifier, guid& transactionidentifier, oletxtransactionisolationlevel& isolationlevel, itransactionshim& transactionshim)    @ system.transactions.transactioninterop.getoletxtransactionfromtransmitterpropigationtoken(byte[] propagationtoken)    --- end of inner exception stack trace ---    @ system.transactions.oletx.oletxtransactionmanager.proxyexception(comexception comexception)    @ system.transactions.transactioninterop.getoletxtransactionfromtransmitterpropigationtoken(byte[] propagationtoken)    @ system.transactions.transactionstatepspeoperation.pspepromote(internaltransaction tx)    @ system.transactions.transactionstatedelegatedbase.enterstate(internaltransaction tx)    @ system.transactions.enlistablestates.promote(internaltransaction tx)    @ system.transactions.transaction.promote()    @ system.transactions.transactioninterop.converttooletxtransaction(transaction transaction)    @ system.transactions.transactioninterop.getexportcookie(transaction transaction, byte[] whereabouts)    @ system.data.sqlclient.sqlinternalconnection.enlistnonnull(transaction tx)    @ system.data.providerbase.dbconnectionpool.prepareconnection(dbconnection owningobject, dbconnectioninternal obj, transaction transaction)    @ system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, uint32 waitformultipleobjectstimeout, boolean allowcreate, boolean onlyonecheckconnection, dbconnectionoptions useroptions, dbconnectioninternal& connection)    @ system.data.providerbase.dbconnectionpool.trygetconnection(dbconnection owningobject, taskcompletionsource`1 retry, dbconnectionoptions useroptions, dbconnectioninternal& connection)    @ system.data.providerbase.dbconnectionfactory.trygetconnection(dbconnection owningconnection, taskcompletionsource`1 retry, dbconnectionoptions useroptions, dbconnectioninternal oldconnection, dbconnectioninternal& connection)    @ system.data.providerbase.dbconnectioninternal.tryopenconnectioninternal(dbconnection outerconnection, dbconnectionfactory connectionfactory, taskcompletionsource`1 retry, dbconnectionoptions useroptions)    @ system.data.sqlclient.sqlconnection.tryopeninner(taskcompletionsource`1 retry)    @ system.data.sqlclient.sqlconnection.tryopen(taskcompletionsource`1 retry)    @ system.data.sqlclient.sqlconnection.open()    @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.<>c__displayclass1.<execute>b__0()    @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute[tresult](func`1 operation)    @ system.data.entity.core.entityclient.entityconnection.open()    --- end of inner exception stack trace ---    @ system.data.entity.core.entityclient.entityconnection.open()    @ system.data.entity.core.objects.objectcontext.ensureconnection()    @ system.data.entity.core.objects.objectcontext.executeintransaction[t](func`1 func, idbexecutionstrategy executionstrategy, boolean startlocaltransaction, boolean releaseconnectiononsuccess)    @ system.data.entity.core.objects.objectquery`1.<>c__displayclassb.<getresults>b__9()    @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute[tresult](func`1 operation)    @ system.data.entity.core.objects.objectquery`1.getresults(nullable`1 formergeoption)    @ system.data.entity.core.objects.objectquery`1.<system.collections.generic.ienumerable<t>.getenumerator>b__0()    @ system.lazy`1.createvalue()    @ system.lazy`1.lazyinitvalue()    @ system.data.entity.internal.lazyenumerator`1.movenext()    @ system.linq.enumerable.todictionary[tsource,tkey,telement](ienumerable`1 source, func`2 keyselector, func`2 elementselector, iequalitycomparer`1 comparer)    @ system.linq.enumerable.todictionary[tsource,tkey,telement](ienumerable`1 source, func`2 keyselector, func`2 elementselector) 

the logic behind code follows,

  1. transaction started

  2. if data there insert, insertion happen

  3. context disposed , recreated here.

  4. 10,000 records fetched

  5. close transaction or roll back.

both time error occurs in step 4. these concern

  1. what issue , why issue not constant?
  2. how skip issue in future?

three options: need enable msdtc on server. or when dispose of context have call .complete() on transaction , dispose of transaction well, creating context outside of original transactionscope. or should able fetch data on original context instead of disposing of first. happens when recreate context inside of transactionscope, treats 2nd connection , promotes need msdtc call.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -