Installation: Cannot open database "Hangfire"


New to Hangfire

Trying to get Hangfire going in a .net core application.

  1. I ran dotnet add package HangFire --version 1.7.0-beta2, that seemed to go fine
  2. Created a connection string:
    ‘“Hangfire”: “Server=localhost,1433;Database=Hangfire;User Id=sa;Password=xxxxxxxxxx;MultipleActiveResultSets=true”’
  3. added services.AddHangfire(s => s.UseSqlServerStorage(Configuration.GetConnectionString("Hangfire"))); to Startup.cs ConfigureServices()
  4. added app.UseHangfireDashboard(); and app.UseHangfireServer(); to Startup.cs Configure()
  5. when app.UseHangfireDashboard();runs it throws an error:

Application startup exception: System.Data.SqlClient.SqlException (0x80131904): Cannot open database "Hangfire" requested by the login. The login failed. Login failed for user 'sa'.

  1. no Hangfire database exists or is created

  2. When in the above process should the database be created/initialized?

  3. Any ideas on this error?

  4. Am I missing an installation step or steps?



I believe it means it cannot connect to your database. Are those the correct login details for your db? I use localdb(sqlexpress) so I just need the basic windows authentication. Connect to the table that you want to connect to using visual studio and get the correct connection string there. That’s my thinking on the error.