79316101

Date: 2024-12-29 18:18:41
Score: 2
Natty:
Report link

I managed to make it work in my project, thanks to the example provided by Svyatoslav Danyliv, the references shared by Alexander Petrov, and the help from the people in the comments. Thank you all!

Basically, what I needed to do was create a DbContext builder. This builder receives the company to be queried, constructs the connection string, and dynamically defines the table names to be queried (only the mapped ones, of course). In the end, it returns a DbContext referencing only the tables and database for that specific company.

I created a demo project for anyone who wants to test it out. If possible, feel free to submit pull requests with suggestions for improvements. I’ve never used EF Core in this way before, so there’s a chance it’s not implemented in the best way.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Breno Pimentel da Silva