Home / Companies / MongoDB / Blog / Post Details
Content Deep Dive

Quick Start: C# and MongoDB - Creating Documents

Blog post from MongoDB

Post Details
Company
Date Published
Author
Ken W. Alger
Word Count
761
Language
English
Hacker News Points
-
Summary

To create documents in a MongoDB database using C#, you can use the MongoDB.Driver from NuGet to establish a connection to a MongoDB server. With a connection established, you can access specific databases and collections, such as `sample_training` and `grades`, respectively. You can then create a new BSON document using the `BsonDocument` class and insert it into the database using methods like `InsertOne()` or `InsertOneAsync()`. The MongoDB C# Driver provides easy-to-use methods for inserting multiple documents at once with `InsertMany()` or `InsertManyAsync()`.