What are the navigation features in the Entity Framework?

I am new to Entity Framework. When Visual Studio creates a model diagram, we can see mainly two things in Entities.Propertie and navigation properties. So what are these navigation features? How to use them?

+4
source share
3 answers

Navigation properties are related objects to the main object. Foreign keys are usually represented by navigation properties.

Example: if you have two tables. The invoice and invoice elements and these tables have a 1-> many relationship, so you will find the navigation property in the invoice object, which lists all the invoice elements associated with the invoice.
Hope this helps.

+6
source

Entity Framework's navigation properties provide a way to navigate between two types of entities. Each object can have a navigation property for each link in which it participates. Navigation properties allow you to navigate and manage relationships in both directions, returning either an EntityReference if the multiplicity is either one, zero or one, or an EntityCollection if there are many.

When using classes created by the Entity Framework, navigation properties are created for objects that participate in relationships.

UPDATE: Here's a nice example of navigation properties for relationships between books, authors, and publishers.

+4
source

The navigation property is mainly used for foreign key relationships in EF. i.e. user to roles, product to categories, etc.

therefore, if you have Order with OrderLines, the navigation property will indicate Order_OrderLineItems, and you will be able to access the elements associated with it.

Look here for some explanations. What are the navigation properties in the Entity Framework for?

+3
source

All Articles