β‘οΈ This library handles schema creation and migrations for Quartz.NET using EntityFrameworkCore migrations toolkit with one line of configuration β‘οΈ
π§ Feel free to create as issue for driver support π§
dotnet add package AppAny.Quartz.EntityFrameworkCore.Migrations.MySql
dotnet add package AppAny.Quartz.EntityFrameworkCore.Migrations.PostgreSQL
dotnet add package AppAny.Quartz.EntityFrameworkCore.Migrations.SQLite
dotnet add package AppAny.Quartz.EntityFrameworkCore.Migrations.SqlServer
β
Configure the DbContext
that will hold the Quartz.NET tables
public class DatabaseContext : DbContext
{
// ...
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Prefix and schema can be passed as parameters
// Adds Quartz.NET MySql schema to EntityFrameworkCore
modelBuilder.AddQuartz(builder => builder.UseMySql());
// Adds Quartz.NET PostgreSQL schema to EntityFrameworkCore
modelBuilder.AddQuartz(builder => builder.UsePostgreSql());
// Adds Quartz.NET SQLite schema to EntityFrameworkCore
modelBuilder.AddQuartz(builder => builder.UseSQLite());
// Adds Quartz.NET SqlServer schema to EntityFrameworkCore
modelBuilder.AddQuartz(builder => builder.UseSqlServer());
}
}
β (Optional) ASP.NET Core Integration Configuration
// Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddQuartz(q =>
{
q.UsePersistentStore(c =>
{
// Use for MySQL database
c.UseMySql(mysqlOptions =>
{
mysqlOptions.UseDriverDelegate<MySQLDelegate>();
mysqlOptions.ConnectionString = ...;
mysqlOptions.TablePrefix = ...;
});
// Use for PostgresSQL database
c.UsePostgres(postgresOptions =>
{
postgresOptions.UseDriverDelegate<PostgreSQLDelegate>();
postgresOptions.ConnectionString = ...;
postgresOptions.TablePrefix = ...;
});
// Use for SQLite database
c.UseSQLite(sqlLiteOptions =>
{
sqlLiteOptions.UseDriverDelegate<SQLiteDelegate>();
sqlLiteOptions.ConnectionString = ...;
sqlLiteOptions.TablePrefix = ...;
});
// Use for SqlServer database
c.UseSqlServer(sqlServerOptions =>
{
sqlServerOptions.UseDriverDelegate<SqlServerDelegate>();
sqlServerOptions.ConnectionString = ...;
sqlServerOptions.TablePrefix = ...;
});
});
});
}
β
Add EntityFrameworkCore migration with Quartz.NET schema dotnet ef migrations add AddQuartz
and then
-
π© Add in-process migration using
databaseContext.Database.MigrateAsync()
-
π© Add out-of-process migration using
dotnet ef database update
-
π© Extract SQL for your migration tool
dotnet ef migrations script PreviousMigration AddQuartz