Skip to main content
All CollectionsC#/.NET Development
C#/.NET Starter Project
C#/.NET Starter Project

This repository contains a basic sample application built with the C# MongoDB Driver that connects to MongoDB Atlas.

Richa Deshpande avatar
Written by Richa Deshpande
Updated over a year ago

Prerequisites

To build and run this project, you will need Visual Studio 2019 Community Edition for MacOS or Windows, which you can download here: VS Community 2019 Downloads.

It is also helpful, but not necessary, to have a working installation of Git version control.

1. Download the Repository

To get started with this sample project, download this repository to your programming environment. You can close this project using Git version control:

git clone git@github.com:mongodb-university/atlas_starter_dotnet.git

Or you can download the ZIP archive using your browser. If you download this project as a ZIP archive, unzip the archive before proceeding.

2. Open the Project

  1. In Visual Studio, select File > Open...

  2. Navigate to the directory containing this project, and then the AtlasStarter folder.

  3. Select the AtlasStarter.sln file, and then click OK.

3. Configure your Atlas Credentials

  1. Open the Program.cs file.

  2. On line 17, replace the placeholder text with the connection string to your Atlas cluster.

var mongoUri = "<Your Atlas Connection String>";

4. Run the Project

  1. Click the Run icon, or from the Run menu, choose Start Debugging.

Assuming you have the correct connection string, you have now connected the C# app to your MongoDB Atlas datastore. Have fun modifying the code to experiment with the C# driver and MongoDB.


โ€‹

Did this answer your question?