Entity Framework Core allows you to use the navigation properties in your model to load related entities. There are three common O/RM patterns used to load related data. Eager loading means that the related data is loaded from the database as part of the initial query.
If you define your navigation property virtual , Entity Framework will at runtime create a new class (dynamic proxy) derived from your class and uses it instead of your original class. This new dynamically created class contains logic to load the navigation property when accessed for the first time.
Navigation property: A property defined on the principal and/or dependent entity that references the related entity. Collection navigation property: A navigation property that contains references to many related entities.
Basically a scalar property is mapped to a column (int, string, ...) A navigation property is mapped to a relation. e.g Order. OrderDetails brings you to all ORderDetails of a specific order.
Yup - it's not that straightforward.
Here's what you do:
1 - Right click on the designer, Add -> Association
2 - Setup the association and cardinalities (People *..1 Gender, People *..1 Race)
3 - Go into the Model Browser -> Associations
4 - Right click on your newly created associations, click Properties
5 - Here you need to setup the endpoints for the key and cascade options. Make sure you get the endpoints correct. You can also setup a referential constraint here for your implicit navigational property.
6 - Map the navigational property to the relevant tables/fields.
7 - Validate your model, cross your fingers.
Hope this helps.
I came across this blog post which proposes the following solution, which worked great for me (unfortunately I could not get RPM1984's to work in my situation).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With