使用.NET在MySQL中保存机器人状态数据 [英] Saving bot state data in mySQL with .NET

查看:87
本文介绍了使用.NET在MySQL中保存机器人状态数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Bot State服务即将停用,因此我想将我的机器人状态信息存储在本地mySQL数据库中.

Since the Bot State service will be retired soon I want to store my bot state information in my local mySQL database.

我尝试使用mySQL连接字符串在Global.asax中实例化SqlBotDataStore客户端,但由于未创建 SqlBotDataEntities 表,我认为我缺少了一些东西.

I tried to instantiate the SqlBotDataStore client in Global.asax using mySQL connection string but I think I'm missing something since SqlBotDataEntities table have not been created.

请就此提出您的建议.谢谢!

Kindly give your suggestions on this. Thanks!

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 }
        );
    });
}

推荐答案

SqlBotDataStore 来自

SqlBotDataStore from https://github.com/Microsoft/BotBuilder-Azure/ has been made for Azure SQL, not MySQL.

您不能在MySQL数据库中使用它.

You can't use it with MySQL database.

此NuGet软件包有2个选项:

You have 2 options with this NuGet package:

  • 天蓝色表存储
  • CosmosDB

这篇关于使用.NET在MySQL中保存机器人状态数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆