EntityWhat is an Entity in Entity Framework?An entity in Entity Framework is a class that maps to a database table. This class must be included as a DbSet Here we are taking the example of Student and Grade domain classes in the school application. The above class becomes the entity when they are included as DbSet In the above context class, Students and Grades properties are the type of DbSet<TEntity> which is called as the set of entity. Student and Grades are entity. Entity Framework API will create the Students and Grades tables in a database. An Entity can include two types of properties: Scalar Properties and Navigation Properties. Scalar Property: The type of primitive property is called scalar properties. Each scalar property maps to a column in the database table which stores the real data. For example, StudentID, StudentName, DateofBirth, height, and weight are the scalar properties in the Student entity class. Entity Framework API will create a column in the database table for each scalar property. Navigation PropertyNavigation Property represents the relationship with another entity. We have two types of Navigation property: Reference Navigation, Collection Navigation. Reference Navigation PropertyIf an entity includes the property of another type of the entity, then it is called as Reference Navigation Property. It points to a single entity and represents the multiplicity of one (1) in the entity-relationship. Entity Framework API will create a ForeignKey column in the table for the navigation properties that point to a PrimaryKey of another table in the database. For example, Grade is reference navigation properties in the following Student Entity Class. In the database, Entity Framework API will create a ForeignKey Grade_GradeID in the Student Table. Collection Navigation PropertyIf an entity includes a property of the generic collection of an entity type, then it is called a collection navigation property. Entity Framework API does not create any column for the navigation property in the related table of an entity. Still, it creates a column in the table of the generic collection entity. For example, a Grade entity contains a generic collection navigation property ICollection<Student>. Here the Student entity is specified as a generic type so that Entity Framework API will create a column GradeID in the Student table in the database. Next TopicEntity Framework Core |