protected override EntityChange GetEntityChange(EntityEntry entityEntry)
        {
            var entity = entityEntry.Entity;

            EntityChangeType changeType;

            switch (entityEntry.State)
            {
            case EntityState.Added:
                changeType = EntityChangeType.Created;
                break;

            case EntityState.Deleted:
                changeType = EntityChangeType.Deleted;
                break;

            case EntityState.Modified:
                changeType = entityEntry.IsDeleted() ? EntityChangeType.Deleted : EntityChangeType.Updated;
                break;

            case EntityState.Detached:
            case EntityState.Unchanged:
            default:
                return(null);
            }

            var entityId = entityEntry.GetPrimaryKeyValue();

            if (entityId == null && changeType != EntityChangeType.Created)
            {
                return(null);
            }

            var entityType = entity.GetType();

            var entityChange = new EntityChange
            {
                ChangeType         = changeType,
                EntityEntry        = entityEntry,
                EntityId           = entityId,
                EntityTypeFullName = entityType.FullName,
                PropertyChanges    = GetPropertyChanges(entityEntry).ToArray()
            };

            return(entityChange);
        }