/brief_SIMPLON_library_management

brief de la semaine du 08/01/24 - 12/01/24

Primary LanguageC#

BRIEF SIMPLON Week from 08/01/2024 to 12/01/2024

Context

Create System Management Book with C# & MONGODB

1 - Install MONGODB Database

Create ATLAS Account and install MONGODB (link attached) : https://www.mongodb.com/cloud/atlas/register OR Install locally with Compass : https://www.mongodb.com/products/tools/compass (the following steps will use Compass )

2 - Create Database (Compass Desktop App)

Add in appsettings.json : -> Name of the database to create -> the name of the collections -> the url to connect to the database ConnectionURI (in local we use : "mongodb://localhost:27017")

image

3 - Connect the Application to the database

Install the driver MONGO DB for c# .NET App and Add the following lines to Programm.cs

builder.Services.Configure<MongoDBSettings>(builder.Configuration.GetSection("MongoDBSettings"));

var serverAccess = builder.Configuration.GetSection("MongoDBSettings:ConnectionURI").Value;

builder.Services.AddSingleton<IMongoClient>(new MongoClient(serverAccess));

image

4 - Launch MONGO DB and RUN the App