使用.NET在mySQL中保存bot状态数据

时间:2017-12-22 08:51:09

标签: c# mysql .net botframework azure-bot-service

由于Bot State服务很快就会退役,我想将我的机器人状态信息存储在我的本地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 }
        );
    });
}

1 个答案:

答案 0 :(得分:0)

来自https://github.com/Microsoft/BotBuilder-Azure/

SqlBotDataStore已针对Azure SQL而非MySQL。

您无法在MySQL数据库中使用它。

此NuGet包有2个选项:

  • Azure表存储
  • CosmosDB