How can I get Quartz.NET AdoJobStore to work with Entity Framework?

  • .NET 4.51
  • Entity Framework 6.x

I have a separate project / assembly that wraps around the core functionality of Quartz.NET. I want to programmatically configure Quartz.NET to store information on SQL Server. Since this is a separate assembly the App.config is very minimal and I want to pass in the connection string. Here is the complete App.config:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>

      

and here is the code I am using to set up Quartz.NET:

properties["quartz.scheduler.instanceName"] = "My Scheduler";
properties["quartz.scheduler.instanceId"] = "MySchedulerId";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.dataSource.default.connectionString"] = aConnectionString;
properties["quartz.dataSource.default.provider"] = "System.Data.SqlClient";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";

      

Value for aConnectionString:

TESTING

"Data Source=.\\SQLEXPRESS;Initial Catalog=xxxxx;Integrated Security=True;MultipleActiveResultSets=True"

      

PRODUCTS

server=sql.server.com;User Id=xxxx;password=xxx;Persist Security Info=True;database=xxxx" providerName="System.Data.SqlClient

      

However, when I try to call GetScheduler (), the following error appears:

Could not Initialize DataSource: default

      

and the inner exception:

{"There is no metadata information for provider 'System.Data.SqlClient'\r\nParameter name: providerName"}

      

So what am I missing here? What do I need to change to make this work?

+3


source to share


1 answer


Quartz does not support connecting the Entity Framework framework, it works without external frameworks. The quartz provider is different from the ADO.NET provider infrastructure. You can see an example program configuration for AdoJobStore in Example 13 . Therefore, the correct value would be SqlServer-20 .



You can also customize the connection string by specifying the connectionStringName parameter , and Quartz will look for that named connection string from the connectionStrings section.

+4


source







All Articles