Consider the following setup with models TodoItem
and Person
modelBuilder.Entity<TodoItem>()
.HasOne(t => t.Assignee)
// for simplicity lets assume a Person is assigned to only TodoItem
.WithOne(p => p.AssignedItem)
.HasForeignKey(t => t.AssigneeId);
modelBuilder.Entity<TodoItem>()
.HasOne(t => t.Reviewer)
.WithOne(p => p.ReviewItem)
// for simplicity lets assume a Person owns only one TodoItem
.HasForeignKey(t => t.ReviewerId);
reflectively, probably using Microsoft.EntityFrameworkCore.Metadata
, how can I figure out that
- the property
TodoItem.Assignee
(as configured inHasOne( ... )
) is associated with the "inverse navigation property"Person.AssignedItem
(as configured in inWithOne( ... )
- and similarly, the property
TodoItem.Reviewer
is "inversely related" toPerson.ReviewItem
I guess I'm trying to figure out how to access the configuration set in the modelBuilder.Hasxxx( ... ) and modelBuilder.Withxxx( ... )
methods.
I need this because I'm reflectively traversing through a query result set of a nested data structure and need to ensure that my algorithm is forward looking.