mongodb-generic-repository icon indicating copy to clipboard operation
mongodb-generic-repository copied to clipboard

Scoped repository/multitenancy

Open attilabicsko opened this issue 1 year ago • 2 comments

Hi! What performance reprecussions should I expect when the repository is configured to be scoped instead of singleton?

In my scenario, I'm trying to implement multitenancy (DB per tenant strategy) with AspNetCore.Identity.MongoDbCore, and I'd like to use a tenant-specific, scoped IMongoDbContext. To make it work I had to change both the IMongoDbContext and IMongoRepository services scoped.

My solution works, and I don't see any I/O bound operations in the Repository initialization, so I'm wondering why you advise it being a singleton. I'm new to MongoDB, so I may be missing something. Thank you in advance!

attilabicsko avatar Apr 30 '23 00:04 attilabicsko