In our company we are going to relaunch a proprietary ERP System and for the backend we will use EFCore for dataaccess.
As usual the database design is not the best, but will do the work. But for EFCore we are facing a problem we are unsure how to handle. We would like to have multiple DbContexts for each domain. But the database does have multiple relations across these boundaries and every table is in the same scheme.
When we would migrate to code-first, so we can manage the db from code, we could not manage all relations because in a DbContext not every relation is used.
-> Is it possible to manage the whole db with those kind of "incomplete" DbContext-Relations with code-first? Or would be the only way to have one extraordinary DbContext? Or is there another way?
So for now the alternative seems to be to go all in for reverse engineering the db into entities and always let overwrite the entities (with scaffolding) when db scheme changes occur.
I already tried to create a single DbContext. With that I can manage the whole Db but it is very unpleasant and the creation of the context lasts horribly long.
Also I tried creating multiple Contexts but then I can not manage relations that are not inside a DbContext.
At this time we are reverse engineering the DbContexts, which works very well. But we need to manage the Database outside the codebase which does add complexity to deployment and versioning.