c# - DbMigration.SqlFile generate SqlException (0x80131904): Transaction context in use by another session -
i have created database migration , in method want execute sql files sqlfile method. each of files contains 2 statements: first drop procedure if exists , second 1 create procedure. both statements finishes go. here exception, got when tried apply migration:
system.data.sqlclient.sqlexception (0x80131904): transaction context in use session. @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception, boolean breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobject stateobj, boolean callerhasconnectionlock, boolean asyncclose) @ system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready) @ system.data.sqlclient.sqlcommand.runexecutenonquerytds(string methodname, boolean async, int32 timeout, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.internalexecutenonquery(taskcompletionsource`1 completion, string methodname, boolean sendtopipe, int32 timeout, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.executenonquery() @ system.data.entity.infrastructure.interception.dbcommanddispatcher.<nonquery>b__0(dbcommand t, dbcommandinterceptioncontext`1 c) @ system.data.entity.infrastructure.interception.internaldispatcher`1.dispatch[ttarget,tinterceptioncontext,tresult](ttarget target, func`3 operation, tinterceptioncontext interceptioncontext, action`3 executing, action`3 executed) @ system.data.entity.infrastructure.interception.dbcommanddispatcher.nonquery(dbcommand command, dbcommandinterceptioncontext interceptioncontext) @ system.data.entity.internal.interceptabledbcommand.executenonquery() @ system.data.entity.migrations.dbmigrator.executesql(migrationstatement migrationstatement, dbconnection connection, dbtransaction transaction, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.infrastructure.migratorloggingdecorator.executesql(migrationstatement migrationstatement, dbconnection connection, dbtransaction transaction, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.dbmigrator.executestatementsinternal(ienumerable`1 migrationstatements, dbconnection connection, dbtransaction transaction, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.dbmigrator.executestatementswithintransaction(ienumerable`1 migrationstatements, dbtransaction transaction, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.dbmigrator.executestatementswithinnewtransaction(ienumerable`1 migrationstatements, dbconnection connection, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.dbmigrator.executestatementsinternal(ienumerable`1 migrationstatements, dbconnection connection, dbinterceptioncontext interceptioncontext) @ system.data.entity.migrations.dbmigrator.executestatementsinternal(ienumerable`1 migrationstatements, dbconnection connection) @ system.data.entity.migrations.dbmigrator.<>c__displayclass30.<executestatements>b__2e() @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.<>c__displayclass1.<execute>b__0() @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute[tresult](func`1 operation) @ system.data.entity.sqlserver.defaultsqlexecutionstrategy.execute(action operation) @ system.data.entity.migrations.dbmigrator.executestatements(ienumerable`1 migrationstatements, dbtransaction existingtransaction) @ system.data.entity.migrations.dbmigrator.executestatements(ienumerable`1 migrationstatements) @ system.data.entity.migrations.infrastructure.migratorbase.executestatements(ienumerable`1 migrationstatements) @ system.data.entity.migrations.dbmigrator.executeoperations(string migrationid, versionedmodel targetmodel, ienumerable`1 operations, ienumerable`1 systemoperations, boolean downgrading, boolean auto) @ system.data.entity.migrations.dbmigrator.applymigration(dbmigration migration, dbmigration lastmigration) @ system.data.entity.migrations.infrastructure.migratorloggingdecorator.applymigration(dbmigration migration, dbmigration lastmigration) @ system.data.entity.migrations.dbmigrator.upgrade(ienumerable`1 pendingmigrations, string targetmigrationid, string lastmigrationid) @ system.data.entity.migrations.infrastructure.migratorloggingdecorator.upgrade(ienumerable`1 pendingmigrations, string targetmigrationid, string lastmigrationid) @ system.data.entity.migrations.dbmigrator.updateinternal(string targetmigration) @ system.data.entity.migrations.dbmigrator.<>c__displayclassc.<update>b__b() @ system.data.entity.migrations.dbmigrator.ensuredatabaseexists(action mustsucceedtokeepdatabase) @ system.data.entity.migrations.infrastructure.migratorbase.ensuredatabaseexists(action mustsucceedtokeepdatabase) @ system.data.entity.migrations.dbmigrator.update(string targetmigration) @ system.data.entity.migrations.infrastructure.migratorbase.update(string targetmigration) @ system.data.entity.migrations.design.toolingfacade.updaterunner.run() @ system.appdomain.docallback(crossappdomaindelegate callbackdelegate) @ system.appdomain.docallback(crossappdomaindelegate callbackdelegate) @ system.data.entity.migrations.design.toolingfacade.run(baserunner runner) @ system.data.entity.migrations.design.toolingfacade.update(string targetmigration, boolean force) @ system.data.entity.migrations.updatedatabasecommand.<>c__displayclass2.<.ctor>b__0() @ system.data.entity.migrations.migrationsdomaincommand.execute(action command) clientconnectionid:923d4c55-19e7-4c7d-b2b6-48c710d2264a error number:3910,state:2,class:16 transaction context in use session.
stored procedures containce requests linked server, can reason of issue?
edit
up method pretty simple:
public override void up() { sqlfile(@"sql\sp_mergedata.sql"); }
i have investigated is related code inside sp. i've tried make simple possible , no errors after that. sp merge statement , linked server selects.
edit 2
i have found reason of issue creating synonym linked server table before executing sp code there no in database. there workaround?
edit 3
issue not exists on machine of team member leave now.
fixed passing true
not mandatory parameter suppresstransaction
Comments
Post a Comment