问题
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