You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
builder.Services.AddDbContext<JobsDbContext>(
x =>x.UseMySql(builder.Configuration.GetConnectionString("JobsConnection"),MySqlServerVersion.LatestSupportedServerVersion));builder.Services.AddQuartzServer(options =>options.WaitForJobsToComplete=true);builder.Services.AddQuartz(q =>{q.UseMicrosoftDependencyInjectionJobFactory();q.UsePersistentStore(c =>{c.UseSerializer<JsonObjectSerializer>();c.UseMySql(options =>{options.UseDriverDelegate<MySQLDelegate>();options.ConnectionStringName="JobsConnection";});});});
After that I ran dotnet ef migrations add AddQuartz --context JobsDbContext and result is this:
Which might be correct - I am not sure (I expected tables to be added).
Anyway I try running my app and I get following exception:
Quartz.SchedulerException
HResult=0x80131500
Message=Could not Initialize DataSource: default
Source=Quartz
StackTrace:
at Quartz.Impl.StdSchedulerFactory.<Instantiate>d__65.MoveNext() in /_/src/Quartz/Impl/StdSchedulerFactory.cs:line 621
at Quartz.Impl.StdSchedulerFactory.<GetScheduler>d__71.MoveNext() in /_/src/Quartz/Impl/StdSchedulerFactory.cs:line 1118
at Quartz.ServiceCollectionSchedulerFactory.<GetScheduler>d__6.MoveNext() in /_/src/Quartz.Extensions.DependencyInjection/ServiceCollectionSchedulerFactory.cs:line 50
at Quartz.QuartzHostedService.<StartAsync>d__7.MoveNext() in /_/src/Quartz.Extensions.Hosting/QuartzHostedService.cs:line 37
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 66
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 76
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 51
at Program.<Main>$(String[] args) in C:\Personal\Development\DiscountedApp\DiscountedApp\Program.cs:line 105
This exception was originally thrown at this call stack:
System.RuntimeTypeHandle.GetTypeByName(string, bool, bool, System.Runtime.CompilerServices.StackCrawlMarkHandle, System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack) in LibraryImports.g.cs
System.RuntimeTypeHandle.GetTypeByName(string, bool, bool, ref System.Threading.StackCrawlMark, System.Runtime.Loader.AssemblyLoadContext) in RuntimeHandles.cs
System.Type.GetType(string, bool) in Type.CoreCLR.cs
Quartz.Util.ObjectUtils.ConvertValueIfNecessary(System.Type, object) in ObjectUtils.cs
Quartz.Util.ObjectUtils.SetPropertyValue(object, string, object) in ObjectUtils.cs
Quartz.Util.ObjectUtils.SetObjectProperties(object, System.Collections.Specialized.NameValueCollection) in ObjectUtils.cs
Inner Exception 1:
ArgumentException: Error while reading metadata information for provider 'MySql' Arg_ParamName_Name
Inner Exception 2:
SchedulerConfigException: Could not parse property 'connectionType' into correct data type: Could not load file or assembly 'MySql.Data, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Inner Exception 3:
FileNotFoundException: Could not load file or assembly 'MySql.Data, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
From my understanding Pomelo.EntityFrameworkCore.MySql is alternative to MySql.Data package. But so be it - I got MySql.Data which I am not really happy about.
After adding MySql.Data I run my project and I get following error in JobStoreSupport.cs on line 340:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlConnectAttrs.InitFramework()
```
So my conclusion - clearly something wrong with having package `MySql.Data` - this is not the correct path to take.
How can I solve this? Anything I am doing completely wrong?
PSI also tried adding ADO.NET package into my project but it didn't really lead anywhere.
Additionally, I am not quite sure how to add configuration to Quartz in ASP.NET Core project as all the docs is not for ASP.NET Core project. For now I added following into my `appsettings.json` and hoping it does something:
```
"quartz": {
"quartz.scheduler.instanceName": "MyScheduler",
"quartz.scheduler.instanceId": "AUTO",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate, Quartz",
"quartz.jobStore.tablePrefix": "QRTZ_",
"quartz.jobStore.dataSource": "default",
"quartz.dataSource.default.provider": "MySql",
"quartz.dataSource.default.connectionString": "myConnectionString",
"quartz.serializer.type": "json"
}
```
But from my understanding we are setting this inside of `UsePersistentStore`.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
I am quite new to Quartz.NET and I am struggling to implement persistent store in ASP.NET Core.
These are package versions I am running:
As I want to use separate database for Quartz I created following
DbContext
:Inside of
Program.cs
:After that I ran
dotnet ef migrations add AddQuartz --context JobsDbContext
and result is this:Which might be correct - I am not sure (I expected tables to be added).
Anyway I try running my app and I get following exception:
From my understanding
Pomelo.EntityFrameworkCore.MySql
is alternative toMySql.Data
package. But so be it - I gotMySql.Data
which I am not really happy about.After adding
MySql.Data
I run my project and I get following error inJobStoreSupport.cs
on line 340:Beta Was this translation helpful? Give feedback.
All reactions