We have a single database with multiple schemas. Company architect wants to have Entity Framework DbContext for each schema. Additionally, foreign key relationships exist between different schemas.
In scaffolding a schema today, received this error:
Error:
For foreign key FK_Customer_TransactionId on table CustomerTransaction, Unable to model the end of the foreign key on principal table inv.Product. This is usually because the principal table was not included in the selection set."
I need to have one schema and 1 table from another schema. It cannot locate the Parent Table on the additional schema to create foreign key off.
Looking for solutions:
(1) Is it bad practice in general to have multiple db contexts for every schema, with foreign keys between different schemas? Do Microsoft and Entity Framework support this?
(2) In Entity Framework Core Scaffold, Is there anyway to scaffold a schema And an additional parent table from another schema?
(3) Or is there method to ignore foreign key property on outside schemas?
dotnet ef dbcontext scaffold
"Server=localhost;Database=DatabasetestTest;Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer -c DatabaseContext
-o Entities\Scaffold
-f
--project C:\Project
--schema CustomerService
Currently using EF Core 2.2
Entity Framework: One Database, Multiple DbContexts. Is this a bad idea?
Using Entity Framework 6 with Multiple DB Schemas but using One DBContext