Skip to content

gopal5raut/3-Tier-DotNET-MongoDB-Docker

Repository files navigation

3-Tier .NET & MongoDB Application

This project is a 3-tier web application built with .NET and MongoDB. The application consists of a presentation layer, a business logic layer, and a data access layer. MongoDB is used as the database to store and manage application data.

Table of Contents

Prerequisites

Before setting up the project, ensure you have the following installed on your machine:

Installation

1. Installing .NET SDK and Runtime

To install the .NET SDK and Runtime, execute the following commands in your terminal:

  1. Install .NET SDK 8.0:

    sudo apt-get update && \
    sudo apt-get install -y dotnet-sdk-8.0
  2. Install .NET Runtime 8.0:

    sudo apt-get update && \
    sudo apt-get install -y aspnetcore-runtime-8.0

2. Installing MongoDB

To install MongoDB, execute the following commands in your terminal:

  1. Add MongoDB's GPG key and repository:

    curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
    sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
    --dearmor
    echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
  2. Install MongoDB:

    sudo apt update
    sudo apt install -y mongodb-org
  3. Enable and Start MongoDB service:

    sudo systemctl enable mongod
    sudo systemctl start mongod

3. Setting Up MongoDB

  1. Install MongoDB Shell:

    Follow the installation guide at MongoDB Shell Installation.

  2. Access MongoDB Terminal:

    To interact with your MongoDB instance, open the MongoDB shell using:

    mongosh
  3. Manipulate Databases and Collections:

    • Show databases:

      show dbs;
    • Use a specific database:

      use db_name;
    • Show collections in the database:

      show collections;
    • Query the Products collection:

      db.Products.find().pretty();

Running the Application

To run the .NET application:

  1. Navigate to the root directory where Program.cs is located.

  2. Build the application:

    dotnet build
  3. Run the application:

    dotnet run

    The application will start, and you can access it in your web browser.

Using MongoDB Shell

To manipulate your MongoDB database using MongoDB Shell:

  1. Start the shell:

    mongosh
  2. Example commands:

    • List all databases:

      show dbs;
    • Switch to a specific database:

      use db_name;
    • Show collections in the current database:

      show collections;
    • Find all documents in a collection:

      db.Products.find().pretty();

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors