How to get the count of referenced entity (by views entityreference result)? For example, a student can register a class. The class node has a date field indicating whether the class is active for registering. The registration node has an entityreference field referencing to the class node. I get the referencing class nodes by using "Views: Filter by an entity reference view" option. This view has a filter of "current date is between the start and the end date". Now, if the count of the reference view result rows is 0, the student should be redirected from the node/add/registration page to an explanation page which tells students there is currently no active classes for registering.
On the module entityreference_count page, it says, 


  Currently this module only works with entityreference fields
  configured to use the "Simple (with optional filter by bundle)"
  option. It does not work with the "Views: Filter by an entity
  reference view" option. This may be addressed in a future release.


How can I make it?
Entity Reference Count


  This Entity Reference Count is in-and-of itself, just another field
  type (called "entityreference_count" in the code) that may be attached
  to any Drupal entity. The field may be configured to select which
  referencing entity types and fields you want to aggregate in the
  count. The counter field is automatically re-calculated when the
  referencing or referenced entity get inserted, updated or deleted. The
  Entity Reference Count's numeric field value may be enabled, displayed
  and manipulated via view modes, through the "Manage Fields" interface
  provided by Drupal core's Field UI, and has built-in Views
  integration.


OR


Make sure Child has an entity reference to Parent.
Create a new view
In Filter Criteria, add a new Type (= Parent)
In Advanced>Other, set Aggregation to YES
In Advanced>Relationships, add a new relationship
for "A bridge to the Content entity that is referencing Content via
field_parent" where field_parent is your entity reference. Call this
"Parents" 
In Fields, add Content: Title and when prompted set its
Aggregation type to Group results together
In Fields, add Field:
Parents and when prompted set its Aggregation type to COUNT
(Distinct)