System.AggregateException
I'm trying to build an API with using MongoDB. Sorry for so much screenshots I just wanted to show you all my work and understand what to change and what are my mistakes. I'm kinda new at .net core










'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BaseApi.Repository.UserRepository Lifetime: Singleton ImplementationType: BaseApi.Repository.UserRepository': Unable to resolve service for type 'MongoDB.Driver.IMongoDatabase' while attempting to activate 'BaseApi.Repository.UserRepository'.)'UserRepository class request a IMongoDatabase from the service providerIMongoDatabase type
MongoDb class
IMongoDatabase, and to do that you must register MongoDb
IMongoDatabase instance, but you are injecting one. And locally creating the connection inside your repo is almost guaranteed to be a very bad idea

builder.Services is your service collection. It needs to contain everything that gets resolved in your applicationMonogDbModelBaseApi.Repository.UserRepository': Unable to resolve service for type 'System.String' while attempting to activate 'BaseApi.MongoDB.MongoDBModel'

UserRepositoryIMongoDatabaseIMongoDatabaseIMongoDatabaseIMongoDatabaseMongoDbMongoDbbuilder.ServicesMonogDbModelSystem.AggregateException: 'Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: BaseApi.Repository.UserRepository Lifetime: Scoped ImplementationType: BaseApi.Repository.UserRepository': Unable to resolve service for type 'System.String' while attempting to activate 'BaseApi.MongoDB.MongoDBModel'.) (Error while validating the service descriptor 'ServiceType: BaseApi.MongoDB.MongoDBModel Lifetime: Scoped ImplementationType: BaseApi.MongoDB.MongoDBModel': Unable to resolve service for type 'System.String' while attempting to activate 'BaseApi.MongoDB.MongoDBModel'.)'