workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

.NET 6 Support

Open marxxxx opened this issue 4 years ago • 2 comments

Currently when using the library in a .NET 6 Application along with Entity Framework Core Based Persistence Providers this does not work as there seem to be inconsistencies between EF Core 6 and 3.1 used in the Persistence Providers.

I tried upgrading the Projects WorkflowCore, WorkflowCore.Persistence.EntityFramework, WorkflowCore.Persistence.Sqlite and WorkflowCore.Persistence.SqlServer by simply chaning the TargetFramework in the .csproj Files to <TargetFramework>net6.0</TargetFramework>, restored packages, recompiled it and it worked.

Upgrading all the projects in the Solution was only blocked by some AWS Packages that were not (yet) available for .NET 6.

Are the any plans to provide an updated NuGet Package Version based on .NET 6 (with EF Core 6) ?

I could create a PR with the changes mentioned above if that helps but not sure about the overall strategy as it could temporarily break other providers.

marxxxx avatar Jan 05 '22 09:01 marxxxx

Hello,

just a quick information.

I just upgraded a web application using workflowCore to .NET 6 and it seems to be working just fine by simply upgrading the workflowCore packages.

I'm using the following version of them:

<PackageReference Include="WorkflowCore" Version="3.6.2" />
<PackageReference Include="WorkflowCore.Persistence.SqlServer" Version="3.6.2" />
<PackageReference Include="WorkflowCore.Providers.Redis" Version="3.6.2" />

And every .NET related packages are using the version 6.0.1.

I still have to extensively test this update but I tried launching a workflow and it executed as expected.

ssougnez avatar Jan 05 '22 09:01 ssougnez

Thank you for your comment which ultimately led me to understanding the situation.

In our .NET 6 based application we were not using EntityFrameworkCore. So the version of EntityFrameworkCore the WorkflowCore-Persistence-Packages rely on was used (3.1). Apparently EntityFrameworkCore 3.1 does not work in a .NET 6 application as i was getting these exceptions:

System.TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
 ---> System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
   at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.EntityFrameworkCore.Query.QueryableMethods..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Query.QueryableMethods.get_Select()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryableMethodNormalizingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.NormalizeQueryableMethod(Expression expression)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPreprocessor.NormalizeQueryableMethod(Expression expression)
   at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPreprocessor.Process(Expression query)
   at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
   at WorkflowCore.Persistence.EntityFramework.Services.EntityFrameworkPersistenceProvider.ProcessCommands(DateTimeOffset asOf, Func`2 action, CancellationToken cancellationToken)
   at WorkflowCore.Services.BackgroundTasks.RunnablePoller.PollCommands()
   at WorkflowCore.Services.BackgroundTasks.RunnablePoller.PollCommands()

So the workaround was to install EntityFrameworkCore 6 directly in my application which was then used by the WorkflowCore Persistence Packages.

To me it was not obvious at first glance so i think it publishing WorkflowCore Packages depending on EntityFrameworkCore 6 would still be benefical in this case.

marxxxx avatar Jan 06 '22 10:01 marxxxx