@Override
public <T, M> CompositeObject migrate(T instance, MigrationStrategy<T, M> migrationStrategy, Class<M> targetType, Class<?>... targetTypes) {
Entity entity = instanceManager.getEntity(instance);
Set<Discriminator> discriminators = datastoreSession.getDiscriminators(entity);
TypeMetadataSet types = metadataProvider.getTypes(discriminators);
TypeMetadataSet effectiveTargetTypes = getEffectiveTypes(targetType, targetTypes);
Set<Discriminator> targetDiscriminators = metadataProvider.getDiscriminators(effectiveTargetTypes);
datastoreSession.migrate(entity, types, discriminators, effectiveTargetTypes, targetDiscriminators);
instanceManager.removeInstance(instance);
CompositeObject migratedInstance = instanceManager.getInstance(entity);
if (migrationStrategy != null) {