# Azure Sql throw SqlException when working with hangfire

**URL:** <https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384>\
**Category:** question\
**Tags:** recurring, sql-azure\
**Created:** [July 17, 2019, 5:25pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384 "2019-07-17T17:25:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Astray\_Messiah](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/astray_messiah/32/1690_2.png) [@Astray\_Messiah](https://discuss.hangfire.io/u/Astray_Messiah)\
**Post date:** [July 17, 2019, 5:25pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384/1 "2019-07-17T17:25:48Z")

</div>

I follow this tutorial to make the background job

> **[Schedule Background Jobs Using Hangfire in .NET Core](https://codeburst.io/schedule-background-jobs-using-hangfire-in-net-core-2d98eb64b196)**
>
> You might have found a variety of use cases of background tasks or scheduled jobs in application development. For example, we can delegate…

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.

How do i make it to work in azure sql?

---

<div class="post-metadata">

**Author:** ![NBroomfield](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/nbroomfield/32/2507_2.png) [@NBroomfield](https://discuss.hangfire.io/u/NBroomfield)\
**Post date:** [April 7, 2021, 2:19pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384/2 "2021-04-07T14:19:57Z")

</div>

Hi did you ever resolve this? I’ve git the same issue:

System.Data.SqlClient.SqlException (0x80131904): Invalid object name ‘HangFire.AggregatedCounter’.

---

<div class="post-metadata">

**Author:** ![Astray\_Messiah](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/astray_messiah/32/1690_2.png) [@Astray\_Messiah](https://discuss.hangfire.io/u/Astray_Messiah)\
**Post date:** [April 7, 2021, 2:54pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384/3 "2021-04-07T14:54:17Z")

</div>

Unfortunately, it’s long time ago that I cannot even clearly remember if i can solve it. But I think it is because AggregatedCounter database is not in your database. Maybe you can run migrations or do something to force your hangfire to add that table

---

<div class="post-metadata">

**Author:** ![EduardoCortez](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/eduardocortez/32/3066_2.png) [@EduardoCortez](https://discuss.hangfire.io/u/EduardoCortez)\
**Post date:** [October 6, 2022, 4:00pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384/4 "2022-10-06T16:00:28Z")

</div>

Do you have the structure of the tables of hangfire?  
I have the same issue:(

---

<div class="post-metadata">

**Author:** ![Astray\_Messiah](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/astray_messiah/32/1690_2.png) [@Astray\_Messiah](https://discuss.hangfire.io/u/Astray_Messiah)\
**Post date:** [October 6, 2022, 4:24pm UTC](https://discuss.hangfire.io/t/azure-sql-throw-sqlexception-when-working-with-hangfire/6384/5 "2022-10-06T16:24:16Z")

</div>

It’s been long since I’m working on C#. So I did not have the copy of the schema anymore.  
But after quick searching, I found the sql file from the hangfire library. Maybe you can try executing the file below.

> <https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.SqlServer/DefaultInstall.sql>
