diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
index 5103037..ac84cff 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
@@ -57,8 +57,18 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
    * {@inheritdoc}
    */
   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
+    // @TODO replace with (new get_called_class())(...$args); once PHP 5.6 is required.
+    $reflection = new \ReflectionClass(get_called_class());
+    $args = static::createArgs($container, $configuration, $plugin_id, $plugin_definition, $migration);
+    return $reflection->newInstanceArgs($args);
+  }
+
+  /**
+   * Constructor arguments.
+   */
+  protected static function createArgs(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
     $entity_type = static::getEntityTypeId($plugin_id);
-    return new static(
+    return [
       $configuration,
       $plugin_id,
       $plugin_definition,
@@ -66,7 +76,7 @@ public static function create(ContainerInterface $container, array $configuratio
       $container->get('entity.manager')->getStorage($entity_type),
       array_keys($container->get('entity.manager')->getBundleInfo($entity_type)),
       $container->get('entity.manager')
-    );
+    ];
   }
 
   /**
diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php
index 77b471f..e729f01 100644
--- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php
+++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php
@@ -9,10 +9,15 @@
 
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\File\FileSystemInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\StreamWrapper\LocalStream;
+use Drupal\Core\StreamWrapper\StreamWrapperInterface;
+use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
 use Drupal\migrate\Entity\MigrationInterface;
-use Drupal\migrate\Plugin\MigratePluginManager;
 use Drupal\migrate\Row;
 use Drupal\migrate\MigrateException;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Every migration that uses this destination must have an optional
@@ -25,9 +30,19 @@
 class EntityFile extends EntityContentBase {
 
   /**
+   * @var \Drupal\Core\File\FileSystemInterface
+   */
+  protected $fileSystem;
+
+  /**
+   * @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
+   */
+  protected $streamWrapperManager;
+
+  /**
    * {@inheritdoc}
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FileSystemInterface $file_system, StreamWrapperManagerInterface $stream_wrapper_manager) {
     $configuration += array(
       'source_base_path' => '',
       'source_path_property' => 'filepath',
@@ -36,6 +51,18 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
       'urlencode' => FALSE,
     );
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager);
+    $this->fileSystem = $file_system;
+    $this->streamWrapperManager = $stream_wrapper_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static function createArgs(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
+    $args = parent::createArgs($container, $configuration, $plugin_id, $plugin_definition, $migration);
+    $args[] = $container->get('file_system');
+    $args[] = $container->get('stream_wrapper_manager');
+    return $args;
   }
 
   /**
@@ -50,13 +77,18 @@ public function import(Row $row, array $old_destination_id_values = array()) {
     // already absolute.
     $source = $this->isTempFile($destination) ? $file : $this->configuration['source_base_path'] . $file;
 
-    $dirname = drupal_dirname($destination);
+    $dirname = $this->fileSystem->dirname($destination);
     if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
       throw new MigrateException(t('Could not create directory %dirname', array('%dirname' => $dirname)));
     }
+    $local =
+      $this->streamWrapperManager->getViaUri($source) instanceof LocalStream &&
+      $this->streamWrapperManager->getViaUri($destination) instanceof LocalStream;
 
     // If the start and end file is exactly the same, there is nothing to do.
-    if (drupal_realpath($source) === drupal_realpath($destination)) {
+    // Also it is impossible to determine this for remote wrappers so do not
+    // even try.
+    if ($local && $this->fileSystem->realpath($source) === $this->fileSystem->realpath($destination)) {
       return parent::import($row, $old_destination_id_values);
     }
 
