We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Scheduling Recurring Job on Application Startup throws Invalid object Name 'Hangfire.Hash' Exception

I am trying to schedule a recurring job in either the Application_Start of Global.asax or even in the Owin startup class but seem to be getting an exception. The exception appears to be a sql exception of Invalid Object name 'HangFire.Hash. I have not experienced this issue when scheduling any other background job or recurring job from within my application logic, it appears to be isolated to trying from within these two places in the application lifecycle. Any help in pointing me in the right direction to resolve this would be greatly appreciated.

hello, did u find a solution for that? I have previously used hangfire for my other projects, but im stuck with this error…

Oh i found it. my connection string was targeting a wrong database… :frowning:

I stuck with this problem too… It’s work perfectly in local…
But when I deploy to azure web service

  1. it will occur -> SqlException: Invalid object name ‘HangFire.Hash’.
    So I decide to put Integrated Security=SSPI; in ConnectionString of azure sql then
  2. it occur -> Windows logins are not supported in this version of SQL Server instead.
1 Like

I am having this same problem on a brand new project. I have PrepareSchemaIfNecessary=True and it’s the same database I used all through testing. It only errors on server deployment.

If your problem is same with me, try checking if it has the Hangfire database on server deployment.

I had this problem, when i don’t add migration with hangfire models.

Apologies for bumping this very old topic, but it’s a top result when searching for this problem online:

You may have this problem because the database user you have configured for the production database does not have CREATE SCHEMA permissions.

You can resolve this by:

  • Temporarily using Integrated Security to run the code first time against the prod DB,
  • or modifying the permissions of the web app’s DB user,
  • or creating another more privileged DB user which Hangfire can use to prepare the schema.

Hope it helps!