With the C # driver, you usually will not use the ability to put the database name in the connection string. It is partially supported to provide some level of compatibility with other drivers.
MongoServer.Create ignores the database name. Any credentials (username / password) in the connection string are used as default credentials for all databases.
MongoDatabase.Create, MongoServer.Create, GetDatabase .
:
var connectionString = "mongodb://localhost/database";
var database = MongoDatabase.Create(connectionString);
:
var connectionString = "mongodb://localhost";
var server = MongoServer.Create(connectionString);
var database = server.GetDatabase("database");
, .