Hangfire using an incorrect database

I have 2 databases on my machine for hangfire. These are HangfireJobs and HangfireJobsForABC .
In my ASP.Net app, I have following startup class.


Also, in my web config I have a connection pointing to HangfireJobsForABC database that is named HangfireJobs . Yet, the code above, does not use HangfireJobsForABC database but always uses HangfireJobs database. This seems like a BUG to me.

<add name="HangfireJobs" connectionString="Data Source=mym\SQLSERVER2014;Initial Catalog=HangfireJobsForABC;User Id=abc;Password=xyz;Pooling=true;Min Pool Size=0; Max Pool Size=50;Connection Timeout=60;" providerName="System.Data.SqlClient" />

This is not a bug as I just found out. It was an error on my part when I noticed nothing was going into the hangfire sql server database from my app localhost/app1 but another hangfire database was being filled with jobs. Actually another app localhost/webjobs with a recurring job was filling up this database since it was also running on my laptop.

When the enqueue code in localhost/app1 was hit, then everything worked perfectly with the correct database getting populated with jobs data. When I wrote this ticket, I was assuming incorrectly that the hangfire enqueue method was being hit in localhost/app1.

So its all good and not a bug. Hangfire is simply awesome and it is very a powerful solution for ASP.Net web apps as I am discovering it now.

1 Like