Quartz.NETQuartz.NET
Home
Features
Blog
Discussions
NuGet
GitHub
Home
Features
Blog
Discussions
NuGet
GitHub
  • Getting Started

    • Overview
    • Quartz 4 Quick Start
    • Tutorial
      • Using Quartz
      • Jobs And Triggers
      • More About Jobs & JobDetails
      • Job Data
      • More About Triggers
      • Querying Jobs and Triggers
      • Simple Triggers
      • Cron Triggers
      • RecurrenceTrigger
      • Time and TimeProvider
      • Trigger and Job Listeners
      • Scheduler Listeners
      • Job Execution Middleware
      • Job Stores
      • Configuration, Resource Usage and Building a Scheduler
      • Building a Scheduler Without a Host
      • Clustering
      • Execution Groups
      • Node Affinity (Preferred Node)
      • Testing
      • Compile-Time Checks
      • Declaring Jobs with Attributes
      • Delegate Jobs
    • Configuration Reference
    • JSON Configuration
    • Cron Expression Reference
    • Multi-Tenancy
    • Comparison
    • Frequently Asked Questions
    • Best Practices
    • Before You Go Live
    • Operating a Cluster
    • Log Events
    • Tenancy Patterns
    • Database Schema
    • Database Schema Changes
    • Migration Guide
    • Troubleshooting
    • API Documentation
  • How To's
    • One-Off Job
    • Rescheduling Jobs
    • Backfill
    • Retrying Failed Jobs
    • Pausing with a Reason
    • Job Continuations
    • Overlap Policy
    • Progress and Execution Logs
    • Job Outcomes
    • Multiple Triggers
    • Job Template
    • Running Quartz under Aspire
    • Quartz.NET with Wolverine
    • Coming from Hangfire
    • Coming from TickerQ
    • Embedding Quartz in a Library
    • Running under an External Leader Election
    • Publishing Trimmed and Native AOT
    • Extending Quartz: what is open, what is closed, and how to ask
    • A Job Store of Your Own
    • A Driver Delegate for a New Database
    • Persisting a Custom Trigger Type
    • A Lock Handler of Your Own
  • Packages

    • Quartz Core Additions

      • Jobs
      • Serialization (System.Text.Json)
      • JSON Serialization
      • Plugins
    • Integrations

      • Aspire Integration
      • Aspire Hosting
      • ASP.NET Core Integration
      • HTTP API
      • HTTP Client
      • Dashboard
      • Dashboard Agent
      • Dashboard Host
      • Entity Framework Core
      • Hosted Services Integration
      • Microsoft DI Integration
      • Multiple Schedulers with Microsoft DI
      • Observability
      • Redis Lock Handler
      • TimeZoneConverter Integration
      • Weasel Schema Management
    • 3rd Party Plugins for Quartz
  • Quartz 3.x

    • Getting Started

      • Quartz 3 Quick Start
      • Tutorial
        • Using Quartz
        • Library Overview
        • Jobs And Triggers
        • More About Jobs
        • More About Triggers
        • Execution Groups
        • Node Affinity (Preferred Node)
        • Simple Triggers
        • Cron Triggers
        • RecurrenceTrigger
        • Trigger and Job Listeners
        • Scheduler Listeners
        • Job Stores
        • Tuning the Scheduler
        • Configuration, Resource Usage and SchedulerFactory
        • Advanced (Enterprise) Features
      • Configuration Reference
      • JSON Configuration
      • Multi-Tenancy
      • Frequently Asked Questions
      • Best Practices
      • Tenancy Patterns
      • Troubleshooting
      • API Documentation
      • Database Schema
      • Database Schema Changes
      • Migration Guide
      • Miscellaneous Features
    • How To's

      • One-Off Job
      • Multiple Triggers
      • Job Template
      • Using the CronTrigger
      • Rescheduling Jobs
    • Packages

      • Quartz Core Additions

        • Dashboard
        • Jobs
        • Serialization (System.Text.Json)
        • Serialization (Newtonsoft Json.NET)
        • Plugins
      • Integrations

        • ASP.NET Core Integration
        • Hosted Services Integration
        • Microsoft DI Integration
        • Multiple Schedulers with Microsoft DI
        • OpenTelemetry Integration
        • OpenTracing Integration
        • Redis Lock Handler
        • TimeZoneConverter Integration
      • 3rd Party Plugins for Quartz
  • Old Releases

    • Quartz 2.x
      • Quartz 2 Quick Start
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
        • CronTrigger Tutorial
      • Configuration Reference
      • Migration Guide
      • API Documentation
    • Quartz 1.x
      • Tutorial
        • Lesson 1: Using Quartz
        • Lesson 2: Jobs And Triggers
        • Lesson 3: More About Jobs & JobDetails
        • Lesson 4: More About Triggers
        • Lesson 5: SimpleTrigger
        • Lesson 6: CronTrigger
        • Lesson 7: TriggerListeners and JobListeners
        • Lesson 8: SchedulerListeners
        • Lesson 9: JobStores
        • Lesson 10: Configuration, Resource Usage and SchedulerFactory
        • Lesson 11: Advanced (Enterprise) Features
        • Lesson 12: Miscellaneous Features of Quartz
      • API Documentation
  • License

Quartz.EntityFrameworkCore puts the ADO.NET job store's tables in your own DbContext. dotnet ef migrations add then creates them, and after a Quartz upgrade adds what the release added. Requires Quartz 4.9 and EF Core 10 or later.

Without EF Core migrations, use ProvisionSchema(), the Weasel packages, or the scripts under database/.

Package

DatabaseEF Core provider
PostgreSQLNpgsql.EntityFrameworkCore.PostgreSQL
SQL ServerMicrosoft.EntityFrameworkCore.SqlServer
MySQLMySql.EntityFrameworkCore (Oracle's); Pomelo.EntityFrameworkCore.MySql once it supports EF Core 10
SQLiteMicrosoft.EntityFrameworkCore.Sqlite
OracleOracle.EntityFrameworkCore
Firebird 3, 4 and 5FirebirdSql.EntityFrameworkCore.Firebird

The package depends on Microsoft.EntityFrameworkCore.Relational 10.0.0 or later and on no provider: the dialect is read from the provider's name.

dotnet add package Quartz.EntityFrameworkCore

Adding the tables

public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // your own entities, then Quartz's tables: the dialect follows the context's provider
        modelBuilder.AddQuartzTables(Database.ProviderName);
    }
}

The tables are the ones ProvisionSchema() creates, generated from the same model: every column with its store type, nullability and default, the keys, the foreign keys with their delete rules, and the indexes with their directions. They are entity types without classes, there for the migrations: the store reads and writes the tables, EF Core never does.

QuartzTablesOptionsDefaultIs
TablePrefixQRTZ_what every table and index name starts with, without a schema
Schemaunset: the model's default schemaPostgreSQL and SQL Server only
modelBuilder.AddQuartzTables(Database.ProviderName, tables =>
{
    tables.Schema = "quartz";      // PostgreSQL and SQL Server; unset: the model's default schema
    tables.TablePrefix = "QRTZ_";  // the default
});

The store's TablePrefix names the same tables: the schema, a dot, the prefix.

services.AddQuartz(q => q.UsePersistentStore(store =>
{
    store.UseSqlServer(connectionString);
    // the same tables: the schema, a dot, the prefix
    store.ConfigureStore(options => options.TablePrefix = "quartz.QRTZ_");
}));
  • Every name is folded as the database folds the store's unquoted ones: to lower case on PostgreSQL, to upper case on Oracle and Firebird.
  • A prefix that makes a name longer than the database takes is refused before anything runs: on Firebird that is 31 bytes, so a prefix of at most 6 bytes of UTF-8, 6 characters of ASCII.
  • Two schedulers with two prefixes can share one model: call AddQuartzTables once for each.

The first migration

dotnet ef migrations add AddQuartz

End its Up with CompleteQuartzSchema(), given the same options as AddQuartzTables:

public partial class AddQuartz : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        // ... the CreateTable and CreateIndex calls dotnet ef wrote ...

        // what the model cannot say: SQLite's delete triggers, MySQL's descending index column
        migrationBuilder.CompleteQuartzSchema();
    }
}
DatabaseCompleteQuartzSchema() adds
SQLitethe four delete triggers that clear a trigger's detail rows on a connection that does not enforce foreign keys
MySQLIDX_QRTZ_T_NFT_ST again, with PRIORITY DESC, which Oracle's provider leaves out
PostgreSQL, SQL Server, Oracle, Firebirdnothing

It is safe to run again: the triggers are created only where missing, and the index is replaced by itself.

A database the scripts created

The tables already exist, from database/tables/, ProvisionSchema() or Weasel. Record the first migration without running it:

  1. Bring the database to this release's schema with database/migrations/. See Database Schema Changes.

  2. Run dotnet ef migrations add AddQuartz with no other model change pending, so that Quartz's tables are all the migration holds.

  3. Empty its Up and its Down, which would drop tables this migration did not create:

    public partial class AddQuartz : Migration
    {
        // the tables are there already, from database/tables or ProvisionSchema();
        // dotnet ef database update records this migration and runs nothing
        protected override void Up(MigrationBuilder migrationBuilder)
        {
        }
    
        // emptied too: the tables were not this migration's to drop
        protected override void Down(MigrationBuilder migrationBuilder)
        {
        }
    }
    
  4. Run dotnet ef database update. It records the migration and runs nothing.

From then on, an upgrade's migration only adds.

Upgrading Quartz

A release that changes the schema changes the model. Until you add a migration, Migrate() throws EF Core's pending model changes error, PendingModelChangesWarning, and dotnet ef migrations has-pending-model-changes reports it.

dotnet ef migrations add UpgradeQuartz
  • The migration adds nullable columns, tables and indexes only, so the previous minor's nodes run beside it.
  • Database Schema Changes lists what each release adds.
  • Keep this package on the same version as Quartz: the model is the schema of its own release.

Limits

  • Constraint names are EF Core's on PostgreSQL, SQL Server, MySQL and SQLite: PK_<table> and FK_<table>_<referenced>_<columns>, cut to the database's identifier length. Oracle and Firebird get the scripts' own, such as QRTZ_TRIGGER_TO_JOBS_FK and FK_QRTZ_TRIGGERS_1. The store never names a constraint.
  • On the first four, a database the scripts created keeps the scripts' constraint names, such as FK_QRTZ_TRIGGERS_QRTZ_JOB_DETAILS on SQL Server and qrtz_triggers_pkey on PostgreSQL, which differ from the snapshot's. Harmless while Quartz's migrations only add.
  • SQL Server writes a default as CAST(0 AS bit) where the script writes 0. Same value.
  • On SQLite, a migration of yours that changes a column of a Quartz table rebuilds the table, which drops its triggers. End it with CompleteQuartzSchema(). Quartz's own migrations never rebuild a table.
  • Oracle's MySQL provider is the only one for EF Core 10. It writes a bool with (1) after its type, which is why the model says tinyint(1), and leaves an index column's direction out, which CompleteQuartzSchema() puts back.
  • EF Core 11 targets net11.0 only. The package is built against EF Core 10 and runs on 11.
Oracle
Migrate() takes no lockThe provider's migration lock does nothing, so nothing stops two nodes from migrating at once. Apply migrations from one process: a deployment step, dotnet ef database update or a migration bundle, not Migrate() in every node's startup
The schemaThe tables go in the schema of the user the migration logs in as, and so does __EFMigrationsHistory; Schema is refused
A store whose TablePrefix names another owner, OWNER.QRTZ_Keep the model's TablePrefix as QRTZ_, and apply the migrations connected as that owner. Not through ALTER SESSION SET CURRENT_SCHEMA: the provider looks for its history table in the login user's USER_TABLES
FlagsVARCHAR2(1), as in the script, so the provider's 23ai BOOLEAN is never used. Oracle 21c needs no UseOracleSQLCompatibility for these tables
Firebird
NamesHeld to 31 bytes, Firebird 3's limit, whichever server opens the database: a prefix of at most 6 bytes of UTF-8, 6 characters of ASCII
migrations script --idempotentNot supported by the provider. Script a range of migrations, script <from> <to>, or use a migration bundle
Index directionsOne per index, so IDX_QRTZ_T_NFT_ST is the script's three columns without PRIORITY DESC; the provider refuses mixed directions
The schemaThe tables go in the connection's database; Schema is refused

Moving off AppAny

AppAny.Quartz.EntityFrameworkCore.Migrations brought EF Core migrations to Quartz.NET first; thanks to its authors for building and keeping it. This package succeeds it on Quartz 4.9. An application on Quartz 3.x keeps AppAny.

The tables have the same names, so the move renames nothing, and it rebuilds no table. It is one migration. AppAny never had Oracle or Firebird, so MoveQuartzTablesFromAppAny refuses them.

  1. Upgrade AppAny to 0.6.3 and migrate. Earlier versions have other indexes.

  2. Replace AppAny's modelBuilder.AddQuartz(q => q.UseSqlServer()) with AddQuartzTables, keeping AppAny's prefix and schema. AppAny puts the tables in schema quartz on PostgreSQL and SQL Server:

    modelBuilder.AddQuartzTables(Database.ProviderName, tables =>
    {
        tables.Schema = "quartz";      // PostgreSQL and SQL Server; unset: the model's default schema
        tables.TablePrefix = "QRTZ_";  // the default
    });
    
  3. Remove the AppAny packages.

  4. Run dotnet ef migrations add MoveToQuartzEntityFrameworkCore, replace the body of Up, and empty Down:

    public partial class MoveToQuartzEntityFrameworkCore : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // replaces everything dotnet ef wrote here; the options are AddQuartzTables's,
            // and Schema is for PostgreSQL and SQL Server only
            migrationBuilder.MoveQuartzTablesFromAppAny(tables => tables.Schema = "quartz");
        }
    
        // one-way: what dotnet ef wrote here would undo the repairs, and rebuild every table on SQLite
        protected override void Down(MigrationBuilder migrationBuilder)
        {
        }
    }
    

    The move is one-way. The Down EF Core wrote reverses the whole difference: on SQL Server it makes STR_PROP_1 to STR_PROP_3 NOT NULL again, which fails once a trigger has stored a NULL there, and narrows INSTANCE_NAME back to 150; on SQLite it rebuilds every table. Emptied, a rollback leaves the moved schema in place.

  5. Run dotnet ef database update with the schedulers stopped.

The snapshot then holds this package's model, and every later migration only adds.

What the move doesPostgreSQLSQL ServerMySQLSQLite
Repairs: AppAny has it wrongthe 3 history indexes AppAny never createdthe same; STR_PROP_1 to STR_PROP_3 nullable; QRTZ_FIRED_TRIGGERS.INSTANCE_NAME 150 to 200 widethe same indexes; IDX_QRTZ_T_NFT_ST with PRIORITY DESCthe same indexes; the delete triggers
Converges: harmless, changed in placeQRTZ_TRIGGERS' foreign key stops cascadingthe same; QRTZ_BLOB_TRIGGERS' foreign key dropped; IS_NONCONCURRENT nullable——
Leaves: harmless, a spelling of the same type, or not changeable in placeboolean for bool on two columnsCRON_TRIGGERS.TIME_ZONE_ID 120 wide; REPEAT_COUNT, TIMES_TRIGGERED bigint; MISFIRE_INSTR smallint33 spellings such as bigint(19); IS_NONCONCURRENT NOT NULL; five cascading foreign keysevery column's spelling, such as text; QRTZ_TRIGGERS' cascading foreign key
Costs: what the database doesbuilds 3 indexes; re-adding the foreign key reads QRTZ_TRIGGERS oncethe same; the column changes are metadata only, but EF Core rebuilds IDX_QRTZ_FT_INST_JOB_REQ_RCVRY over INSTANCE_NAMEbuilds 3 indexes; rebuilds IDX_QRTZ_T_NFT_STbuilds 3 indexes; creates 4 triggers
  • On SQL Server, AppAny's NOT NULL string properties fail every calendar-interval and recurrence trigger, which leave STR_PROP_2 and STR_PROP_3 empty: "Cannot insert the value NULL into column 'STR_PROP_2'".
  • What it leaves stays in the database as AppAny made it, for no difference the store sees. Changing it would narrow a column; rewrite every row of QRTZ_TRIGGERS and rebuild its acquisition index (MISFIRE_INSTR on SQL Server); rebuild QRTZ_FIRED_TRIGGERS, since MySQL makes a column nullable only by rebuilding the table; copy a table to change a foreign key on MySQL; or rebuild every table on SQLite.

See also

  • Job stores: the ADO.NET store and its schema
  • Database Schema Changes: every schema version and its migration
  • Weasel: the same tables under Weasel, as Marten and Wolverine manage theirs
Help us by improving this page!
Last Updated: 11/23/26, 12:50 PM
Contributors: Marko Lahma, Claude Opus 5.5
Prev
Dashboard Host
Next
Hosted Services Integration