Postgresql Devart EF : The underlying provider failed on Open

c# devart entity-framework-6 postgresql transactions

Question

i got this exception when executing a simple read query using entity framework on our Postgre Db, in the code, which throw this exception, i dont use transactions the code do not fail systematically but randomly

this the stack trace :

{
  "Depth": 0,
  "ClassName": "System.Data.Entity.Core.EntityException",
  "Message": "The underlying provider failed on Open.",
  "Source": "EntityFramework",
  "StackTraceString": "   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()\r\n   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)\r\n   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()\r\n   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()\r\n   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)\r\n  ......,
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": {
    "Name": "Open",
    "AssemblyName": "EntityFramework",
    "AssemblyVersion": "6.0.0.0",
    "AssemblyCulture": "",
    "ClassName": "System.Data.Entity.Core.EntityClient.EntityConnection",
    "Signature": "Void Open()",
    "MemberType": 8
  },
  "HResult": -2146233087,
  "HelpURL": null
},
{
  "Depth": 1,
  "ClassName": "System.InvalidOperationException",
  "Message": "The current TransactionScope is already complete.",
  "Source": "System.Transactions",
  "StackTraceString": "   at System.Transactions.Transaction.get_Current()\r\n   at Devart.Common.DbConnectionFactory.a(DbConnectionBase A_0)\r\n   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)\r\n   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)\r\n   at Devart.Common.DbConnectionBase.Open()\r\n   at Devart.Data.PostgreSql.PgSqlConnection.Open()\r\n   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)\r\n   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()",
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": {
    "Name": "get_Current",
    "AssemblyName": "System.Transactions",
    "AssemblyVersion": "4.0.0.0",
    "AssemblyCulture": "",
    "ClassName": "System.Transactions.Transaction",
    "Signature": "System.Transactions.Transaction get_Current()",
    "MemberType": 8
  },
  "HResult": -2146233079,
  "HelpURL": null
}

in the Db the transaction are enabled, i set the max_prepared_transactions = max_connections =100

i m using Devart provider with EF for a Postgresql database

any idea why/when this exception happen ?

1
0
6/5/2018 8:21:35 AM

Accepted Answer

problem fixed by setting TransactionScopeAsyncFlowOption.Enabled when creating the transactionscope

https://particular.net/blog/transactionscope-and-async-await-be-one-with-the-flow

1
6/11/2018 2:01:41 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow