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

There was an error using Mysql in .net 5.0

Open yefengwz opened this issue 3 years ago • 6 comments

using Mysql in .net 5.0

Error------------------------------- System.AggregateException HResult=0x80131500 Message=One or more errors occurred. (Could not load type 'Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=5.0.0.0, Culture=neutral, PublicKeyToken=2cc498582444921b'.) Source=System.Private.CoreLib StackTrace: at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at WorkflowCore.Services.WorkflowHost.Start() at TestWorkflowCore.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in D:\TestWorkflowCore\Startup.cs:line 51 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app) at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder) at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.<Configure>b__0(IApplicationBuilder app) at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.GenericWebHostService.<StartAsync>d__31.MoveNext()

Inner Error------------------------------- TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=5.0.0.0, Culture=neutral, PublicKeyToken=2cc498582444921b'.

Code------------------------------- var host = app.ApplicationServices.GetService<IWorkflowHost>(); host.RegisterWorkflow<EventSampleWorkflow, MyDataClass>(); host.Start(); **//error here** Package------------------------------- Microsoft.EntityFrameworkCore 5.0.6 Newtonsoft.Json 13.0.1 Pomelo.EntityFrameworkCore.MySql 5.0.0 Swashbuckle.AspNetCore 6.1.4 WorkflowCore 3.5.0 WorkflowCore.Persistence.MySQL 3.5.0

thanks a lot

yefengwz avatar May 17 '21 01:05 yefengwz

Hello, I am new to this framework and I am trying to create a console application using workflow core and using MySql as a Database and based on the sample I am able to establish the MySQL connection and few tables got created in the database but now I am trying to create a new table in DB and trying to read data from that table but not able to do this, Please suggest to me how to proceed on this?.

venugopal8 avatar Jul 14 '21 07:07 venugopal8

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1138

FatuityCookie avatar Jul 23 '21 08:07 FatuityCookie

I thought maybe upgrade to NETStandard 2. 1, can solve this problem

FatuityCookie avatar Jul 23 '21 08:07 FatuityCookie

I also found this problem, web app reference class library, host.Start(); //error here in class library

FatuityCookie avatar Jul 23 '21 08:07 FatuityCookie

Use source code to upgrade to .NETStandard 2. 1 and then it works

yefengwz avatar Jul 30 '21 02:07 yefengwz

Use source code to upgrade to .NETStandard 2. 1 and then it works

Use source code to upgrade to .NETStandard 2. 1 and then it works Hello,When I use Net6.0, the same problem occurs, when I config like this: builder.Services.AddWorkflow(x => x.UseMySQL("XXX", true , true));//bool canCreateDB, bool canMigrateDB both true ,then host.Start()//error
but this: builder.Services.AddWorkflow(x => x.UseMySQL("XXX", false , false)); //bool canCreateDB, bool canMigrateDB both false,then host.Start(),it works. then MysqlContext.cs -> OnConfiguring method add #elif NET6_0_OR_GREATER. I use source code to upgrade to .NET6.0 and then it works.

Hi7t avatar Jul 13 '22 01:07 Hi7t