Types of Entity in Entity Framework

There are two types of Entities in Entity Framework 5.0/6.0: POCO entity and dynamic proxy entity.

  1. POCO Entity (Plain Old CLR Object)
    1. POCO class is the class that doesn’t depend on any framework specific base class. It is like any other normal .net class which is why it is called “Plain Old CLR Objects”.
    2. These POCO entities (also known as persistence-ignorant objects) support most of the same query, insert, update, and delete behaviors as entity types that are generated by the Entity Data Model.
  2. Dynamic Proxy (POCO Proxy)
    1. Dynamic Proxy is a runtime proxy class of POCO entity. It is like a wrapper class of POCO entity. Dynamic proxy entities allow lazy loading and automatic change tracking.
    2. POCO entity should meet the following requirements to become a POCO proxy:
      1. A POCO class must be declared with public access.
      2. A POCO class must not be sealed (NotInheritable in Visual Basic)
  • A POCO class must not be abstract (MustInherit in Visual Basic).
  1. Each navigation property must be declared as public, virtual
  2. Each collection property must be ICollection<T>
  3. ProxyCreationEnabled option must NOT be false (default is true) in context class

By default dynamic proxy is enabled for every entity. However, you can disable dynamic proxy by setting the ProxyCreationEnabled option to false in context class.

context.Configuration.ProxyCreationEnabled = false;

EDM generates POCO entities which satisfy the above requirements for a dynamic proxy by default.

At runtime, type of Student will be System.Data.Entity.DynamicProxies.Student as below:


Scalar properties:

Scalar properties are properties whose actual values are contained in the entity. For example, Student entity has scalar properties like StudentId and StudentName. These correspond with the Student table columns.

Navigation properties:

Navigation properties are pointers to other related entities. The Student has Standard property as a navigation property that will enable the application to navigate from a Student to related Standard entity.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s