I am looking for a way to set up my context so that when it populates a particular property of a particular entity, it pulls the data from a different table. Something similar to this fake syntax (assuming navigation properties are already in place) and made-up schema:
modelBuilder.Entity<MyEntity>(entity => {
entity.Property(e => e.PropFromOtherTable)
// the magic I'm looking for
.PopulateFrom(e => e.Destination?.Hotel.Contact.Id ?? 0);
}
Ideally I’d like to do this in the model builder so the property will be populated in all the places this entity is being used, without having to explicitly ask for the property in any given query.
I realize I can use Select to get any shape I want, but my primary motivator here is avoiding having to change the signatures of 40+ methods and 150+ unit tests, and without having to pull in a ton of extra data (ultimately, I just need the contact id, I don’t need hotels or contacts).