I have connected MongoDB to .NET and I'm trying to save data into the database. The program works fine and my data is inserted into the database, but my understanding from the documentation is that I should be able to see everything that is occurring in the console window as well. This is my sample program that I'm working on.
static void Main(string[] args)
{
MainAsync().Wait();
Console.ReadLine();
}
static async Task MainAsync()
{
var client = new MongoClient("mongodb://localhost:27017");
IMongoDatabase db = client.GetDatabase("machines");
var collection = db.GetCollection<BsonDocument>("cranes");
var document = new BsonDocument
{
{ "code", BsonValue.Create("0x657")},
{ "departments", new BsonArray(new[] {"Mech", "Forge"}) },
};
await collection.InsertOneAsync(document);
}
This is the console output I am seeing when running the program.
I can see that the data has been succesffully added in MongoDB Compass, but I do not have any feedback in the console window.