我的web应用是在asp.net MVC中使用mysql数据库。
下面是hangfire的配置。
public void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(configuration => {
configuration.UseStorage(
new MySqlStorage(
"server=127.0.0.1;uid=root;pwd=root;database={0};Allow User Variables=True",
new MySqlStorageOptions
{
TablesPrefix = "Hangfire"
}
)
);
};
}
我得到excepton表 hangfireSet
未找到。在数据库中表创建为 hangfireset
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TableName>().ToTable("tablename");
}
我怎样才能在OnModelCreating中访问hangfire模型类,以便我可以将表名改为小写。
自 Hangfire
不是ContextDb的一部分,那么你就不能用这种方式改变它的表名。相反,你可以在 Hangfire
配置。
services.AddHangfire(cfg => cfg
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage("YOURCONNECTIONSTRING",
new Hangfire.SqlServer.SqlServerStorageOptions
{
/* other configs */
SchemaName = "Your own scheme"
}));