Authenticate RunCommand. Command authenticate failed: BSON field 'authenticate.mechanism' is missing but a required field

public bool Authenticate(string username, string password)
        {
            var cmd = new BsonDocument("authenticate", new BsonDocument
            {
                {"username",username },
                {"password",password },
                {"mechanism", "SCRAM-SHA-1"}
            });

            var queryResult = _context.Database.RunCommand<BsonDocument>(cmd);

            return true;
        }

Exception occurs when executing this method “Command authenticate failed: BSON field ‘authenticate.mechanism’ is missing but a required field”

How to fix?

This topic was automatically closed after 180 days. New replies are no longer allowed.