Why is the returned Hangfire jobId a string, when it's stored as a bigint in the Job table?


BackgroundJob.Enqueue (documented here Background Methods — Hangfire Documentation) returns a nullable string

performContext.BackgroundJob.Id (‘documented’ here Use Hangfire job id in the code) returns a string

Looking at the Job table in the db, the primary key Id is a bigint (c# long equivalent)

a) in my code I am saying ‘if i can’t convert this string to a long then something went wrong with registering the job, and if I CAN convert it to a long, then the job exists’. Am I wrong with that thinking?

b) just curious why isn’t a long or nullable long returned directly? what kind of other information might possibly be included in the string/nullable string return types?


Hangfire supports various types of data stores. Forcing it to be numeric could limit implementations in other data stores, like document databases. If your data store isn’t going to change then you’re safe to assume it is a bigint/long/int64.