由于 Bot State 服务即将停用,我想将我的 bot 状态信息存储在我的本地 mySQL 数据库中。
我尝试使用 mySQL 连接字符串在 Global.asax 中实例化 SqlBotDataStore 客户端,但我认为我缺少一些东西,因为SqlBotDataEntities
尚未创建表。
请就此提出您的建议。谢谢!
protected void Application_Start(object sender, EventArgs e)
{
{
var config = GlobalConfiguration.Configuration;
Conversation.UpdateContainer(
builder =>
{
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["mySQL_ConnectionString"].ConnectionString);
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
// Register your Web API controllers.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(config);
});
config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
}
// WebApiConfig stuff
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
});
}