Skip to content

MongoDB

In this lab, we will work with the MongoDB NoSQL database and the Mongo C# driver.

Pre-requisites and preparation

Required tools to complete the tasks:

  • Windows, Linux, or macOS: All tools are platform-independent, or a platform-independent alternative is available.
  • MongoDB Community Server (download)
  • Robo 3T (download)
  • Sample database initialization script: (mongo.js)
  • GitHub account and a git client
  • Microsoft Visual Studio 2019/2022 with the settings here
    • When using Linux or macOS, you can use Visual Studio Code, the .NET Core SDK, and dotnet CLI.
  • .NET Core 3.1 SDK

    .NET Core 3.1

    Mind the version! You need .NET Core SDK version 3.1 to solve these exercises.

    On Windows it might already be installed along with Visual Studio (see here how to check it); if not, use the link above to install (the SDK and not the runtime). You need to install it manually when using Linux or macOS.

Materials for preparing for this laboratory:

  • MongoDB database system and the C# driver
    • Check the materials of Data-driven systems including the seminars
  • Official Microsoft tutorial for WebApi using MongoDB
    • We will not be creating a WebApi in this lab, but the Mongo part is the same.

Initial steps

Keep in mind that you are expected to follow the submission process.

Create and check out your Git repository

  1. Create your git repository using the invitation link in Moodle. Each lab has a different URL; make sure to use the right one!

  2. Wait for the repository creation to complete, then check out the repository.

    If you are not asked for credentials to log in to GitHub in university computer laboratories when checking out the repository, the operation may fail. This is likely due to the machine using someone else's GitHub credentials. Delete these credentials first (see here), then retry the checkout.

  3. Create a new branch with the name solution and work on this branch.

  4. Open the checked-out folder and type your Neptun code into the neptun.txt file. There should be a single line with the 6 characters of your Neptun code and nothing else in this file.

Create the database

Follow the steps in the seminar material to start the database server and initialize the database.

Back to top