Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use MongoDB
dotnet add package MongoDB.Driver
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ServiceStack;
using ServiceStack.DataAnnotations;
using MongoDB.Driver;
namespace MyApp
public class ConfigureMongoDb : IConfigureServices
IConfiguration Configuration { get; }
public ConfigureMongoDb(IConfiguration configuration) => Configuration = configuration;
public void Configure(IServiceCollection services)
var mongoClient = new MongoClient();
IMongoDatabase mongoDatabase = mongoClient.GetDatabase("MyApp");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment