代码之家  ›  专栏  ›  技术社区  ›  Frank Parsons

使用在mySQL中保存bot状态数据。净额

  •  1
  • Frank Parsons  · 技术社区  · 7 年前

    由于Bot状态服务即将退役,我想将我的Bot状态信息存储在本地mySQL数据库中。

    我尝试在全局中实例化SqlBotDataStore客户机。asax使用mySQL连接字符串,但我想我缺少了一些东西 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 回复  |  直到 7 年前
        1
  •  0
  •   Nicolas R    7 年前

    SqlBotDataStore 从…起 https://github.com/Microsoft/BotBuilder-Azure/ 已为Azure SQL而不是MySQL创建。

    您不能将其用于MySQL数据库。

    此NuGet软件包有两个选项:

    • Azure表存储
    • 宇宙数据库