简体   繁体   中英

Hangfire Database in Development Mode

I am using Hangfire in my ASP.NET Core application. It is still in development, now Every time I run the app I want Hangfire to delete the old Database and create a new Database for each run.

Currently when I Run the application the Hangfire Dashboard still shows old jobs even the ones that are no longer in my Code.

Is the something like below I can perform when configuring Hangfire

HangFirecontext.Database.EnsureDeleted();
HangFirecontext.Database.EnsureCreated();

As far as I know there is no way to programatically remove the Hangfire tables. I think your best option is to drop the tables by executing regular SQL statements as soon as the application started. Hangfire will automatically re-create the tables for you. Alternatively, you can call SqlServerObjectsInstaller.Install() (or the equivalent of another database provider) to re-create the tables right after you dropped them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM