Hangfire doesn't create tables in IIS

六月ゝ 毕业季﹏ 提交于 2020-01-25 00:10:07

问题


I have installed Hangfire in my ASP.Core 2.2 project using this guide https://docs.hangfire.io/en/latest/getting-started/aspnet-core-applications.html .

When I delete my MyProject_devMSSQL db and run Update-Database only my custom tables are created. After I run the project, the Hangfire tables are added.

In appsettings.production.json I have configured the db to be MyProject_prod and I click on Folder publish with checked Entity Framework Migrations so the build process can create a .sql file in the EFSQLScripts folder with the SQL I need to apply to the MyProject_prod database.

The problem is that the .sql file contains only my custom tables. When I run the IIS site the Hangfire tables aren't created in MyProject_prod db, in comparison to when I run the project with F5 locally, where they are created in MyProject_dev if they do not exists. Looking at the logs I see that the connection to the MyProject_prod db is made, the error is:

[ERR] Execution BackgroundServerProcess is still in the Failed state for 00:20:45.1406056 due to an exception, will be retried no more than in 00:00:15
System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'HangFire.Server'.

I could export the tables from my MyProject_dev db and import them in the MyProject_prod db, but I don't think this would be the right approach. Why aren't the tables created when the app is run under IIS?


回答1:


Try creating the database manually in production, without adding any tables. In your config, point it at the newly created db. This may be an issue with hangfire bot having the permissions to build create the database.



来源:https://stackoverflow.com/questions/58029407/hangfire-doesnt-create-tables-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!