【问题标题】:Hangfire still points to old database even after changing the connection string即使更改了连接字符串,Hangfire 仍然指向旧数据库
【发布时间】:2020-05-16 16:58:29
【问题描述】:

我在一个 asp.net 核心应用程序中运行 Hangfire,我想更改它连接到的数据库。更改数据库后,我发现 Hangfire 仍然从日志中连接到旧数据库。如何更改为新数据库?

这是我的hangfire配置

services.AddHangfire(configuration => configuration
            .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings()
            .UseSqlServerStorage(Configuration.GetConnectionString("HandFireCon"), new SqlServerStorageOptions
            {
                CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
                SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
                QueuePollInterval = TimeSpan.Zero,
                UseRecommendedIsolationLevel = true,
                UsePageLocksOnDequeue = true,
                DisableGlobalLocks = true
            }));

【问题讨论】:

    标签: asp.net-core hangfire


    【解决方案1】:

    您是否尝试使用调试器查看您为方法UseSqlServerStorage(Configuration.GetConnectionString("HandFireCon") 获得了什么值?

    您为解决方案拥有的配置文件很可能仍然具有旧的数据库名称。

    【讨论】:

    • 配置不同。我确保将数据库名称更改为旧名称
    猜你喜欢
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2019-12-11
    • 1970-01-01
    相关资源
    最近更新 更多