我正在asp.net mvc应用程序中工作,我想设置用户请求提醒, 在startup.cs类中,我配置了hangfire。但是它给出了异常,关键字不受支持:“元数据”。当阅读此行代码GlobalConfiguration.Configuration时 .UseSqlServerStorage(“ DbEntities”);
using Hangfire;
using Hangfire.SqlServer;
using Microsoft.Owin;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UKC.Data.Infrastructure;
using UKC.UI.Helper;
[assembly: OwinStartup(typeof(UKC.UI.App_Start.Startup))]
namespace UKC.UI.App_Start
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
GlobalConfiguration.Configuration
.UseSqlServerStorage("DbEntities");
}
}
}
答案 0 :(得分:0)
就我而言,这是因为配置文件中的连接字符串不正确。
<add name="HangfireEntities" connectionString="metadata=res://*/Model.DBModel.csdl|res://*/Model.DBModel.ssdl|res://*/Model.DBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=localhost;initial catalog=HangfireTest;persist security info=True;user id=sa;password=myStrongPassw0rd;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
应该
<add name="HangfireEntities" connectionString="Server=.\\localhost; Database=HangfireTest;user id=sa;password=myStrongPassw0rd" providerName="System.Data.EntityClient" />