I have a FooDbContext
inheriting from BarContext
.
In BarContext
, with Schema Bar
, I have an object Bar
.
In FooDbContext
, with Schema Foo
, I have an object Foo
, which has an BarFK
and Bar
Navigation property.
In BarDbContext
's OnModelCreation
method I've defined Bar:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// define Foo...
modelBuilder.Entity<Foo>...etch...
}
And In FooDbContext
's OnModelCreation
method, I've defined Foo and Ignored
the "inherited" Bar
entity:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// define Foo...
modelBuilder.Entity<Foo>...etch...
// Then ignore Bar
modelBuilder.Ignore(Bar);
}
I've seeded it with a record to check and run Migrations.
It nearly works. In that it doesn't complain.
The BarFK value is filled as per the seeding -- but when I perform the query with .Include(x=>x.Bar)
it complains that type Bar is not part of the model.
I'm not 100% sure, but pretty sure it would work if they both had the same Schema.
But it's hugely important to this app that I can keep the schema's distinct if at all possible.
Is it possible? If so....how?!?
Thanks!