0

I've got two entities with one-to-one relationship, let's call them Parent and Child. In the database, the Child table has a FK to Parent.

What I need to achieve is to have a navigation property to Child on Parent. The project doesn't use Fluent API, but uses attributes.

Can someone help me? In the end, I want to be able to use it something like this:

Set<Parent>().Include(w => w.ChildNavigationProp)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Branislav B.
  • 509
  • 7
  • 21
  • https://stackoverflow.com/questions/4461762/how-to-annotate-a-parent-child-relationship-with-code-first. Hope this helps – amit agarwal Mar 06 '23 at 18:55
  • https://learn.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key here you have full example of relationships in ef core. First examples shows how ef core does it by default implicitlly, but you can do it manually by fluent api or data annotations. – KJanek Mar 07 '23 at 12:03

0 Answers0