Saving bot state data in mySQL with .NET

為{幸葍}努か 提交于 2021-01-28 10:06:10

问题


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

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

回答1:


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

You can't use it with MySQL database.

You have 2 options with this NuGet package:

  • Azure Table Storage
  • CosmosDB


来源:https://stackoverflow.com/questions/47938472/saving-bot-state-data-in-mysql-with-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!