I updated a project to ASP.NET Core 2 today and I get the following error:
Cannot consume scoped service IMongoDbContext from singleton IActiveUsersSe
You can't use a service with a smaller lifetime. Scoped services only exist per-request, while singleton services are created once and the instance is shared.
Now only one instance of IActiveUsersService exists in the app. But it wants to depend on MongoDbContext, which is Scoped, and is created per-request.
You will have to either:
MongoDbContext a Singleton, orIActiveUsersService Scoped, orMongoDbContext into the user service as a function argument