private static void MoveDefaultDiscriminator(
     StorageMappingFragment fromFragment, StorageMappingFragment toFragment)
 {
     var discriminatorColumn = fromFragment.GetDefaultDiscriminator();
     if (discriminatorColumn != null)
     {
         var discriminator = fromFragment.ColumnConditions.SingleOrDefault(
             cc => cc.ColumnProperty == discriminatorColumn);
         if (discriminator != null)
         {
             fromFragment.RemoveDefaultDiscriminatorAnnotation();
             fromFragment.RemoveConditionProperty(discriminator);
             toFragment.AddDiscriminatorCondition(discriminator.ColumnProperty, discriminator.Value);
             toFragment.SetDefaultDiscriminator(discriminator.ColumnProperty);
         }
     }
 }
        private static StorageMappingFragment FindConditionTypeMappingFragment(
            EntitySet tableSet, StorageMappingFragment propertiesTypeMappingFragment, StorageEntityTypeMapping conditionTypeMapping)
        {
            var table = tableSet.ElementType;

            var conditionTypeMappingFragment
                = conditionTypeMapping.MappingFragments
                                      .SingleOrDefault(x => x.Table == table);

            if (conditionTypeMappingFragment == null)
            {
                conditionTypeMappingFragment
                    = EntityMappingOperations
                        .CreateTypeMappingFragment(conditionTypeMapping, propertiesTypeMappingFragment, tableSet);

                conditionTypeMappingFragment.SetIsConditionOnlyFragment(true);

                if (propertiesTypeMappingFragment.GetDefaultDiscriminator() != null)
                {
                    conditionTypeMappingFragment.SetDefaultDiscriminator(
                        propertiesTypeMappingFragment.GetDefaultDiscriminator());
                    propertiesTypeMappingFragment.RemoveDefaultDiscriminatorAnnotation();
                }
            }
            return conditionTypeMappingFragment;
        }