C# - 底层提供程序在Open上失败。当前的TransactionScope已经完成

时间:2018-01-22 14:54:13

标签: c# sql-server

我收到错误,我找不到理由。 错误如下:

  

System.Data.Entity.Core.EntityException:底层提供程序在Open上失败。        - &GT; System.InvalidOperationException:当前的TransactionScope已经完成。              在System.Transactions.Transaction.get_Current()              at System.Data.ProviderBase.DbConnectionPool.GetFromTransactedPool(Transaction&amp; transaction)              在System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions userOptions,DbConnectionInternal&amp; connection)              at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource 1 retry,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal&amp; connection)              在System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1重试)              在System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 1 retry) at System.Data.SqlClient.SqlConnection.Open() at System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch [TTarget,TInterceptionContext](TTarget目标,Action 2 operation, TInterceptionContext interceptionContext, Action 3执行,Action 3 executed) at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func 1操作)              在System.Data.Entity.Core.EntityClient.EntityConnection.Open()              ---内部异常堆栈跟踪结束---              在System.Data.Entity.Core.EntityClient.EntityConnection.Open()              在System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)              at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction [T](Func 1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery 1.&lt;&gt; c__DisplayClass3.b__1()              at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute [TResult](Func 1 operation) at System.Data.Entity.Core.Objects.ObjectQuery 1.GetResults(Nullable 1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery 1..GetEnumerator&gt; b__0()              在System.Data.Entity.Internal.LazyEnumerator 1.MoveNext() at System.Collections.Generic.List 1..ctor(IEnumerable 1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable 1来源)              在DFStore.Business.Core.Helpers.Settings.GetGlobalSettingValues()              在DFStore.Business.Core.Helpers.Settings.GetGlobalSetting [T](String key)              在DFStore.ExternalSystemConnector.DocumentManagementConnector.FileDownloaderConnector.OnDoOperation(Dictionary`2 tInput)

我的代码中找不到任何TransactionScope:

using (var dbRepository = new DbRepository<ManagementDbContext>())
                {
                    listGlobalSettingValue = dbRepository.Select<GlobalSettingValue>().Include(x => x.SettingDefinition).ToList();
                }

非常感谢任何帮助。

提前致谢。

0 个答案:

没有答案