Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting SQL Server error while using Hangfire

I am using Hangfire in an ASP.NET MVC5 application to send an email. Until now, it was working fine, but now when I run the application, it is throwing this error:

There is already an object named 'Job' in the database.nstalling Hangfire SQL objects... Database schema [HangFire] already exists Table [HangFire].[Schema] already exists.. Installing schema version 1

From this error, I understood that Hangfire trying to create all those tables in the database which are already there. But I'm not getting reason behind it because till now application was working fine, even when I run it locally many times.

like image 421
Dreamer Avatar asked Dec 16 '16 04:12

Dreamer


People also ask

Does HangFire need a database?

HangFire. AspNetCore HangFire into the application. The web application has a database for the application's data. And by default, the HangFire database tables were created in the same database where the application's data resides.

What is HangFire SQL Server?

Hangfire. An easy and reliable way to perform fire-and-forget, delayed and recurring, long-running, short-running, CPU or I/O intensive tasks inside ASP.NET applications. No Windows Service / Task Scheduler required. Even ASP.NET is not required. Backed by Redis, SQL Server, SQL Azure or MSMQ.


2 Answers

This happened to me and I run this query and restart the server. Just run the query:

INSERT INTO [HangFire].[Schema]
           ([Version])
     VALUES
           (5)
like image 51
tripurary Avatar answered Sep 28 '22 11:09

tripurary


I got that problem after export\import the database via .bacpac finished with errors. I removed all my hangfire tables on development database and it worked (careful, do not do that on production DB).

DROP TABLE IF EXISTS HangFire.AggregatedCounter
DROP TABLE IF EXISTS HangFire.Counter
DROP TABLE IF EXISTS HangFire.Hash
DROP TABLE IF EXISTS HangFire.JobParameter
DROP TABLE IF EXISTS HangFire.JobQueue
DROP TABLE IF EXISTS HangFire.List
DROP TABLE IF EXISTS HangFire.[Schema]
DROP TABLE IF EXISTS HangFire.Server
DROP TABLE IF EXISTS HangFire.[Set]
DROP Table IF EXISTS HangFire.State
DROP TABLE IF EXISTS HangFire.Job
like image 34
Liam Kernighan Avatar answered Sep 28 '22 11:09

Liam Kernighan