zzzprojects / EntityFramework-Classic

Entity Framework Classic is a supported version of the latest EF6 codebase. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.
https://entityframework-classic.net
Other
103 stars 27 forks source link

InvalidOperationException when using .Future() within a transaction #6

Closed neoGeneva closed 5 years ago

neoGeneva commented 5 years ago

When attempting to use .Future() and QueryFutureEnumerable.ToListAsync() within a transaction I get the following exception:

InvalidOperationException: BeginExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
  System.Data.SqlClient.SqlCommand+<>c.<ExecuteDbDataReaderAsync>b__122_0(Task<SqlDataReader> result)
  System.Threading.Tasks.ContinuationResultTaskFromResultTask<TAntecedentResult, TResult>.InnerInvoke()
  System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state)
  System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref Task currentTaskSlot)
  .(CancellationToken cancellationToken)
  Z.EntityFramework.Classic.QueryFutureBatch.ExecuteQueriesAsync(CancellationToken cancellationToken)
  Z.EntityFramework.Classic.QueryFutureEnumerable<T>.ToListAsync(CancellationToken cancellationToken)
  ...

Version: Z.EntityFramework.Classic 7.0.12 OS: Windows 10 TargetFramework: netcoreapp2.1

JonathanMagnan commented 5 years ago

Hello @neoGeneva ,

Thank a lot, we will try it on our side.

Best Regards,

Jonathan


Performance Libraries context.BulkInsert(list, options => options.BatchSize = 1000); Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper PlusLinqToSql Plus

Runtime Evaluation Eval.Execute("x + y", new {x = 1, y = 2}); // return 3 C# Eval FunctionSQL Eval Function

JonathanMagnan commented 5 years ago

Hello @neoGeneva ,

The v7.0.13 has been released.

The library should now honor the transaction if one is started.

Let me know if that issue is fixed on your side.

Best Regards,

Jonathan

neoGeneva commented 5 years ago

Hey, I just got the latest release and the fix works great, thanks!