79077960

Date: 2024-10-11 11:15:59
Score: 1
Natty:
Report link

If I understood the question correctly, you are looking for, is to reduce redundant code, and Keep a method close to changes, yet open to extensions

There is a SOLID principle that is focused just around that, its called The Open Closed Principle (The "O" in SOLID) and it is a principle that helps us solving exactly these use-cases.

One way to solve it would be to use something like a dictionary, iterate through every DbContext in your instance and only add new contexts to that db, However it doesn't sound like the most elegant solution.

I'd recommend diving into OCP and checking out what solutions it offers, as this is more of a problematic design choice, which can be solved really, in many different ways.

I would highly recommend learning SOLID better if you are not familiar enough with it.

Good luck! :)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Aviv