Skip to main content

MySQL

MySQL supports both the Master database and Agent transport layers.

Install​

dotnet add package JobMaster.MySql

Configuration​

builder.Services.AddJobMasterCluster(config =>
{
config.ClusterId("My-Cluster")
.UseMySqlForMaster("Server=...;Database=...;User Id=...;Password=...;TrustServerCertificate=True;");

config.AddAgentConnectionConfig("MySql-1")
.UseMySqlForAgent("Server=...;Database=...;User Id=...;Password=...;TrustServerCertificate=True;");
});
note

Add UseAffectedRows=True to your connection string and tune innodb_buffer_pool_size for higher throughput.

Options​

Table prefix​

By default, JobMaster creates tables with the JM_ prefix. Override it via the tablePrefix parameter on UseMySqlForMaster/UseMySqlForAgent:

config.UseMySqlForMaster("Server=...;Database=...;User Id=...;Password=...;TrustServerCertificate=True;", tablePrefix: "myapp_jm_");

config.AddAgentConnectionConfig("MySql-1")
.UseMySqlForAgent("Server=...;Database=...;User Id=...;Password=...;TrustServerCertificate=True;", tablePrefix: "myapp_agent_");

Also available through ConfigFromJson's connectionOptions: {"tablePrefix": "myapp_jm_"}.

Migrating from UseSqlTablePrefixForMaster/UseSqlTablePrefixForAgent

Those generic methods are now [Obsolete] — they applied regardless of which provider a connection actually used, which didn't make much sense (e.g. calling UseSqlTablePrefixForMaster on a RavenDB-master cluster). They still compile and behave the same; migrate to the tablePrefix parameter above at your convenience.

Disable auto schema provisioning​

By default, JobMaster creates and migrates its tables on startup. Disable this if you manage schema migrations yourself:

config.UseMySqlForMaster("...")
.DisableAutoProvisionSqlSchema();