I'm working on solution on the following stack:
...using this driver for communication with the database: https://www.nuget.org/packages/MongoDB.Driver.Core/ ...version 2.4.1
I'm trying to instantiate the MongoClient like this:
var options = provider.GetService<IOptions<MongoDbSettings>>();
var client = new MongoClient(options.Value.ConnectionString);
But the last statement errors out saying:
An exception of type 'System.MissingMethodException' occurred in MongoDB.Driver.dll but was not handled in user code
and
Additional information: Method not found: 'Void MongoDB.Driver.ReadPreference..ctor
I've noticed that the class MongoClient is in the MongoDB.Driver -namespace, not in MongoDB.Driver.Core. Does that mean it is not compatible with .Net Core? If so, how do I then connect to the database?
All help appreciated!
Regards, Jon
I ended up using this driver: http://mongodb.github.io/mongo-csharp-driver/
version 2.3.0, which solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With