简体   繁体   English

Hangfire数据库处于开发模式

[英]Hangfire Database in Development Mode

I am using Hangfire in my ASP.NET Core application. 我在ASP.NET Core应用程序中使用Hangfire 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. 它仍在开发中,现在每次运行应用程序时,我都希望Hangfire删除旧数据库并为每次运行创建一个新数据库。

Currently when I Run the application the Hangfire Dashboard still shows old jobs even the ones that are no longer in my Code. 目前,当我运行应用程序时, Hangfire Dashboard仍会显示旧作业,即使是不在我的代码中的作业。

Is the something like below I can perform when configuring Hangfire 在配置Hangfire时我可以执行以下Hangfire

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

As far as I know there is no way to programatically remove the Hangfire tables. 据我所知,没有办法以编程方式删除Hangfire表。 I think your best option is to drop the tables by executing regular SQL statements as soon as the application started. 我认为您最好的选择是在应用程序启动后立即执行常规SQL语句来删除表。 Hangfire will automatically re-create the tables for you. Hangfire会自动为您重新创建表格。 Alternatively, you can call SqlServerObjectsInstaller.Install() (or the equivalent of another database provider) to re-create the tables right after you dropped them. 或者,您可以在删除表后立即调用SqlServerObjectsInstaller.Install() (或其他数据库提供程序的等效项)来重新创建表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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