MongoDB.Driver.MongoAuthenticationException: Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1

Last Updated on May 6, 2022 by Pupli

The issue is you are authenticating the mongoadmin user for clientdb. But mongoadmin user is authenticated to admin db. Get the mongoadmin user authenticated and then you can access clientdb.

IMongoClient _client;
        public readonly IMongoDatabase _database;

        public MongoContext_URIBased()
            var mongoUrl = new MongoUrl("mongodb://mongoadmin:secret@");
            _client = new MongoClient(mongoUrl);
            _database = _client.GetDatabase("clientdb");