Atlas Compass C Sharp Mongo Setup Guide
Atlas Compass C Sharp Mongo Setup Guide
About
This guide will walk you through setting up a MongoDB development environment including the
use of Atlas (cloud based database as a service or DBAS for Mongo), Compass (GUI application
for exploring your MongoDB data and running queries), C# Drivers and will show you basic CRUD
operations in C#.
Atlas
• Follow this guide to getting started with Atlas:
https://www.mongodb.com/resources/products/platform/mongodb-atlas-tutorial
o Follow guide through “Creating a cluster user” section
o You do not need to complete “Generating a database connection string” section
and after yet (you will come back to do that later
• Note: make sure the user you create has read/write access to your cluster
• Note: under the network configuration step, you may want to allow access from
anywhere:
Compass
• Download and install Compass:
https://www.mongodb.com/docs/compass/current/install/
• Connect to your Atlas cluster:
o You will need a database user (created in Atlas setup step)
o Go through the connection wizard to generate your connection string:
• IMPORTANT NOTE: be careful with your database connection string. Best practice is to
store this in a configuration file that is not committed to your repo. If your connection
string is committed to a public repository, other users will have direct access to your
database.
• Docs: https://www.mongodb.com/docs/drivers/csharp/current/
• Quick Start: https://www.mongodb.com/docs/drivers/csharp/current/quick-start/
• Guide:
o Create a new C# project
o Add System.Configuration.ConfigurationManager NuGet packate to your project
o Add an app.config file to your project: