Types of properties in Entity Framework

An entity is a class in your application which is included as DbSet .
Basically EF API maps each entity to a table and each property of an entity to a column in the database.
Let us take the following entities as examples,

using system.ComponentModel.DataAnnotations;
public class Customer
{ [key]
public int CustID{get;set;}
public string CustName{get;set;}
public customeraddress customeraddress{get;set;}
public orders orders{get;set;}
}
";


using system.ComponentModel.DataAnnotations;
public class customeraddress
{ [key]
public int customeraddressid{get;set;}
public string address1{get;set;}
public customer customer{get;set;}
}


using system.ComponentModel.DataAnnotations;
public class orders
{ [key]
public int orderid{get;set;}
public datetime orderdate{get;set;}
public ICollection customers{get;set;}
}

Let us create context class for above entities.

using system.ComponentModel.DataAnnotations;
public class CustomerContext:DbContext
{ public CustomerContext(){}
public DbSet customers{get;set;}
public DbSet customeraddresses{get;set;}
public DbSet orders{get;set;}
}

In the above context class customers,customeraddresses and orders properties of type DbSet and are called entity sets.
Now comes the 2 properties of Entity Framework
Scalar Property

The primitive type properties are called scalar properties.
It stores the actual data.It maps to single column in database table.



Navigation Property

The navigation property represents relationship to another entity.
There are two type of navigation 1.Reference navigation 2.Collection Navigation


Reference Navigation

if an entity includes property of another entity type then it is called reference navigation property.


Collection Navigation

If an entity includes property of collection type then it is called collection navigation.