This package allows you to store your custom data in a NoSQL MongoDB database. Unlike most NoSQL databases, a MongoDB server can be installed on almost any platform, your laptop or on a Cloud service like AWS, GCP or Azure. It avoids vendor lock-in into any specific hosting platform.
- Setup a MongoDB server either locally on your laptop or you can use the MongoDB free hosting plan to create an instance on AWS, GCP or Azure.
- Update
appsettings.json
file with the connection string to the above database
{
"MongoDbCredentials": {
"ConnectionString": "<mandatory> mongodb+srv://cluster0.fyu.mongodb.net/?authSource=%24external&authMechanism=MONGODB-X509&retryWrites=true&w=majority",
"CertificateFilePathWithName": "<optional Certificate file path with name [pfx file]>",
"CertificatePassword": "<optional Certificate password>"
}
}
- Install this package
Sample code
var database = MongoDBClientConnection.GetDatabase("YouDatabaseName");
var collection = database.GetCollection<T>("YourCollectionName"); // of type T
For more examples on how to Insert, Modify your data, check the MongoDB official documentation: https://www.mongodb.com/docs/drivers/csharp/current/quick-reference/
This is a free package, but if you want to sponsor my open source work, here is my GitHub profile