I am getting the MongoServer does not contain a definition for 'Create' exception while compiling the below code. Please help me on this.
Libraries and versions
List<Info> names = new List<Info>();
String name = "";
MongoServer server = MongoServer.Create(
ConfigurationManager.AppSettings["connectionString"]);
MongoDatabase myDB = server.GetDatabase("ES");
MongoCollection<Info> Persons = myDB.GetCollection<Info>("MyCollection");
foreach (Info Aperson in Persons.FindAll())
{
name = name + " " + Aperson.Name;
names.Add(Aperson);
}
The MongoServer.Create()
method was removed in version 2.0. It has been deprecated since at least version 1.7.
Instead, use MongoClient
. To get access to the MongoServer
, use MongoClient.GetServer()
MongoClient client = new MongoClient(
ConfigurationManager.AppSettings["connectionString"]);
MongoServer server = client.GetServer();
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