0

I am using MongoDB C# driver "2.13.0" with MongoDB.Bson version "2.13.0" to connect and insert and retrieve data from MongoDB.

Now as per official website the document limit is 16 MB max.

But when I am trying to insert data which is in KB's if I put it in Notepad but the code is complaining the size limit.

System.FormatException: Size 16948171 is larger than MaxDocumentSize 16793600

 MongoURL = new MongoUrl("...");
 MongoClientSettings = MongoClientSettings.FromUrl("");
 MongoClient mongoClient = new MongoClient("");
 dbConnection = mongoClient.GetDatabase("DatabaseName");
 ................
 collection.InsertOne(new {});

But when I am using file to insert from MongoDB shell using command it's working fine. Means it's not complaining for the size there.

शेखर
  • 17,412
  • 13
  • 61
  • 117
  • What version driver is MongoDB shell using? Reading the link the file size is different depending on the driver. You are using an old driver which may account for the error. – jdweng Nov 07 '22 at 06:43
  • @jdweng MongoDB shell I am not sure how to find that. Also that Driver is specific to C# language. – शेखर Nov 07 '22 at 10:56
  • Read the link you posted. The size is different depending on driver being used. See following to get version : https://stackoverflow.com/questions/38160412/mongodb-how-to-find-the-exact-version-of-installed-mongodb?force_isolation=true – jdweng Nov 07 '22 at 11:31
  • @jdweng thanks but from MongoDB shell and MongoDB C# driver are pointing to the same MongoDB database. – शेखर Nov 07 '22 at 11:56
  • It is not the database. Read your link. It is the version of the driver. – jdweng Nov 07 '22 at 12:52
  • @शेखर How are you creating the document to store in the collection? [Importing some JSON?](https://mongodb.github.io/mongo-csharp-driver/2.13/examples/importing_json/) – rickhg12hs Nov 12 '22 at 14:42
  • what do you mean when you say you put it in the notpad..which notepad you talking about..could you specify more about the non-working method you said. – mr.Penguin Nov 13 '22 at 11:06
  • @ExtraHassan notepad means - creating insert statement and executing it via MongoDB shell. – शेखर Nov 15 '22 at 12:45

0 Answers0