Botframework 如何使用SQL保存ConversationState和UserState Bot Framework v4
我目前正在将我的bot框架v3迁移到v4 有没有办法在SQL数据库上存储Bot状态 我在这里看到了有关Bot状态的文档: 但它只能节省CosmoDB或Azure存储空间。在bot framework v4上没有关于在SQL中保存状态的可用文档 在我的bot framework v3中,我有以下代码将bot状态保存到SQL数据库:Botframework 如何使用SQL保存ConversationState和UserState Bot Framework v4,botframework,Botframework,我目前正在将我的bot框架v3迁移到v4 有没有办法在SQL数据库上存储Bot状态 我在这里看到了有关Bot状态的文档: 但它只能节省CosmoDB或Azure存储空间。在bot framework v4上没有关于在SQL中保存状态的可用文档 在我的bot framework v3中,我有以下代码将bot状态保存到SQL数据库: var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["statedb"].C
var store = new SqlBotDataStore(ConfigurationManager.ConnectionStrings["statedb"].ConnectionString);
Conversation.UpdateContainer(
builder =>
{
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store,
CachingBotDataStoreConsistencyPolicy
.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
builder.RegisterModule(new ReflectionSurrogateModule());
builder.RegisterModule<GlobalMessageHandlersBotModule>();
});
var store=new SqlBotDataStore(ConfigurationManager.ConnectionStrings[“statedb”].ConnectionString);
Conversation.UpdateContainer(
生成器=>
{
builder.Register(c=>store)
.Keyed(AzureModule.Key_数据存储)
.AsSelf()
.SingleInstance();
builder.Register(c=>新的CachingBotDataStore(store,
cachingbotdatastoreconsistency策略
.ETAGBASED(一致性)
.As()
.AsSelf()
.InstancePerLifetimeScope();
RegisterModule(新的ReflectionSurrogateModule());
builder.RegisterModule();
});
我希望bot framework v4具有类似的功能bot framework社区为bot Builder v4提供了EntityFramework存储。可以找到源代码,该库作为nuget包提供 它的使用方式与其他V4
IStorage
提供程序相同:
var entityFrameworkStorage = new EntityFrameworkStorage(Config["SqlConnectionString"]);
services.AddSingleton<IStorage>(dataStore);
services.AddSingleton<UserState>();
services.AddSingleton<ConversationState>();
var entityFrameworkStorage=newentityframeworkstorage(配置[“SqlConnectionString”]);
服务。AddSingleton(数据存储);
services.AddSingleton();
services.AddSingleton();
更多信息可在此处找到:
我们是否需要了解如何应用迁移才能使其工作?不,不需要“提供迁移”,除非您来自V3?。您可以在此处找到一个示例项目: