This functionality enables seamless integration of MongoDB storage into your existing project. With this integration, you can easily store and retrieve data using MongoDB as your backend storage system.
- Robust and scalable MongoDB storage solution
- Easy configuration and registration of MongoDB storage using extension methods
- Support for custom serialization of allowed types
To get started, follow these steps:
-
Install the required package
Bot.Builder.Community.Storage.MongoDBfor your project -
Add the following using statements to your project:
using Bot.Builder.Community.Storage.MongoDB;- In the ConfigureServices method of your Startup.cs file, add the following code to configure and register MongoDB storage:
services.AddMongoDbStorage(settings =>
{
settings.ConfigureOptions(Configuration.GetSection("MongoDb"));
settings.RegisterTypes(
typeof(YourType1),
typeof(YourType2)
);
});Replace YourType with the type(s) you want to store in
- Update your appsettings.json file to include the MongoDB configuration settings:
{
"MongoDb": {
"ConnectionString": "your_connection_string",
"Database": "your_database_name",
"Collection": "your_collection_name"
}
}Replace your_connection_string, your_database_name, and your_collection_name with the appropriate values for your MongoDB instance.