Example #1
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual bool CanSetField(string?fieldName, ConfigurationSource?configurationSource)
        {
            if (configurationSource.Overrides(Metadata.GetFieldInfoConfigurationSource()))
            {
                if (fieldName == null)
                {
                    return(true);
                }

                var fieldInfo = PropertyBase.GetFieldInfo(
                    fieldName, Metadata.DeclaringType, Metadata.Name,
                    shouldThrow: configurationSource == ConfigurationSource.Explicit);

                return(fieldInfo != null &&
                       PropertyBase.IsCompatible(
                           fieldInfo, Metadata.ClrType, Metadata.DeclaringType.ClrType, Metadata.Name,
                           shouldThrow: configurationSource == ConfigurationSource.Explicit));
            }

            return(Metadata.FieldInfo?.GetSimpleMemberName() == fieldName);
        }
Example #2
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual SkipNavigation SetInverse([CanBeNull] SkipNavigation inverse, ConfigurationSource configurationSource)
        {
            var oldInverse = Inverse;
            var isChanging = inverse != Inverse;

            if (inverse == null)
            {
                Inverse = null;
                _inverseConfigurationSource = null;

                return(isChanging
                    ? (SkipNavigation)DeclaringEntityType.Model.ConventionDispatcher
                       .OnSkipNavigationInverseChanged(Builder, inverse, oldInverse)
                    : inverse);
            }

            if (inverse.DeclaringEntityType != TargetEntityType)
            {
                throw new InvalidOperationException(
                          CoreStrings.SkipNavigationWrongInverse(
                              inverse.Name, inverse.DeclaringEntityType.DisplayName(), Name, TargetEntityType.DisplayName()));
            }

            if (inverse.JoinEntityType != null &&
                JoinEntityType != null &&
                inverse.JoinEntityType != JoinEntityType)
            {
                throw new InvalidOperationException(
                          CoreStrings.SkipInverseMismatchedJoinType(
                              inverse.Name, inverse.JoinEntityType.DisplayName(), Name, JoinEntityType.DisplayName()));
            }

            Inverse = inverse;
            UpdateInverseConfigurationSource(configurationSource);

            return(isChanging
                ? (SkipNavigation)DeclaringEntityType.Model.ConventionDispatcher
                   .OnSkipNavigationInverseChanged(Builder, inverse, oldInverse)
                : inverse);
        }
Example #3
0
 public InternalPropertyBuilder([NotNull] Property property, [NotNull] InternalModelBuilder modelBuilder, bool existing)
     : base(property, modelBuilder)
 {
     if (existing)
     {
         if (Metadata.IsNullable != null)
         {
             _isRequiredConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.IsConcurrencyToken != null)
         {
             _isConcurrencyTokenConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.IsReadOnlyAfterSave != null)
         {
             _isReadOnlyAfterSaveConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.IsReadOnlyBeforeSave != null)
         {
             _isReadOnlyBeforeSaveConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.IsShadowProperty != null)
         {
             _isShadowPropertyConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.ClrType != null)
         {
             _clrTypeConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.RequiresValueGenerator != null)
         {
             _requiresValueGeneratorConfigurationSource = ConfigurationSource.Explicit;
         }
         if (Metadata.ValueGenerated != null)
         {
             _valueGeneratedConfigurationSource = ConfigurationSource.Explicit;
         }
     }
 }
Example #4
0
    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public virtual bool CanSetInverse(
        SkipNavigation?inverse,
        ConfigurationSource?configurationSource)
    {
        if (!configurationSource.Overrides(Metadata.GetInverseConfigurationSource()) ||
            (inverse != null &&
             !configurationSource.Overrides(inverse.GetInverseConfigurationSource())))
        {
            return(Equals(Metadata.Inverse, inverse));
        }

        if (inverse == null)
        {
            return(true);
        }

        return(Metadata.TargetEntityType == inverse.DeclaringEntityType &&
               Metadata.DeclaringEntityType == inverse.TargetEntityType &&
               (Metadata.JoinEntityType == null ||
                inverse.JoinEntityType == null ||
                Metadata.JoinEntityType == inverse.JoinEntityType));
    }
Example #5
0
        private void MergeConfigurationSourceWith(InternalRelationshipBuilder builder)
        {
            var inverted = builder.Metadata.EntityType != Metadata.EntityType;

            Debug.Assert(inverted ||
                         (builder.Metadata.EntityType == Metadata.EntityType && builder.Metadata.ReferencedEntityType == Metadata.ReferencedEntityType));
            Debug.Assert(!inverted ||
                         (builder.Metadata.EntityType == Metadata.ReferencedEntityType && builder.Metadata.ReferencedEntityType == Metadata.EntityType));

            var targetForeignKeyPropertiesConfigurationSource = inverted
                ? builder._referencedKeyConfigurationSource
                : builder._foreignKeyPropertiesConfigurationSource;
            var targetReferencedKeyConfigurationSource = inverted
                ? builder._foreignKeyPropertiesConfigurationSource
                : builder._referencedKeyConfigurationSource;

            _foreignKeyPropertiesConfigurationSource =
                targetForeignKeyPropertiesConfigurationSource?.Max(_foreignKeyPropertiesConfigurationSource) ?? _foreignKeyPropertiesConfigurationSource;

            _referencedKeyConfigurationSource =
                targetReferencedKeyConfigurationSource?.Max(_referencedKeyConfigurationSource) ?? _referencedKeyConfigurationSource;
        }
Example #6
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void SetProperties(
            IReadOnlyList <Property> properties, Key principalKey, ConfigurationSource?configurationSource)
        {
            Validate(properties, principalKey, DeclaringEntityType, PrincipalEntityType);

            var oldProperties   = Properties;
            var oldPrincipalKey = PrincipalKey;

            DeclaringEntityType.OnForeignKeyUpdating(this);

            Properties   = properties;
            PrincipalKey = principalKey;

            DeclaringEntityType.OnForeignKeyUpdated(this);

            if (configurationSource != null)
            {
                UpdatePropertiesConfigurationSource(configurationSource.Value);
                UpdatePrincipalKeyConfigurationSource(configurationSource.Value);
            }

            DeclaringEntityType.Model.ConventionDispatcher.OnForeignKeyPropertiesChanged(Builder, oldProperties, oldPrincipalKey);
        }
Example #7
0
        public virtual bool ValueGenerated(ValueGenerated?valueGenerated, ConfigurationSource configurationSource)
        {
            if (configurationSource.CanSet(_valueGeneratedConfigurationSource, Metadata.ValueGenerated.HasValue) ||
                Metadata.ValueGenerated == valueGenerated)
            {
                _valueGeneratedConfigurationSource = configurationSource.Max(_valueGeneratedConfigurationSource);

                Metadata.ValueGenerated = valueGenerated;

                if (Metadata.IsKey())
                {
                    UseValueGenerator(
                        valueGenerated == Entity.Metadata.ValueGenerated.OnAdd
                            ? true
                            : (bool?)null,
                        ConfigurationSource.Convention);
                }

                return(true);
            }

            return(false);
        }
Example #8
0
    public static bool Overrides(this ConfigurationSource newConfigurationSource, ConfigurationSource?oldConfigurationSource)
    {
        if (oldConfigurationSource == null)
        {
            return(true);
        }

        if (newConfigurationSource == ConfigurationSource.Explicit)
        {
            return(true);
        }

        if (oldConfigurationSource == ConfigurationSource.Explicit)
        {
            return(false);
        }

        if (newConfigurationSource == ConfigurationSource.DataAnnotation)
        {
            return(true);
        }

        return(oldConfigurationSource != ConfigurationSource.DataAnnotation);
    }
Example #9
0
        public virtual InternalRelationshipBuilder Unique(bool?isUnique, ConfigurationSource configurationSource)
        {
            if (((IForeignKey)Metadata).IsUnique == isUnique)
            {
                Metadata.IsUnique            = isUnique;
                _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource);
                return(this);
            }

            if (Metadata.PrincipalToDependent != null)
            {
                // TODO: throw for explicit
                return(null);
            }

            if (_isUniqueConfigurationSource != null &&
                !configurationSource.Overrides(_isUniqueConfigurationSource.Value))
            {
                return(null);
            }

            _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource);
            return(ReplaceForeignKey(configurationSource, isUnique: isUnique));
        }
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetIsRequired(bool?required, ConfigurationSource?configurationSource)
 => ((configurationSource.HasValue &&
      configurationSource.Value.Overrides(Metadata.GetIsNullableConfigurationSource())) ||
     (Metadata.IsNullable == !required)) &&
 (required != false ||
  Metadata.ClrType.IsNullableType());
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetConversion([CanBeNull] Type providerClrType, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetProviderClrTypeConfigurationSource()) ||
 Metadata.GetProviderClrType() == providerClrType;
Example #12
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdatePrincipalEndConfigurationSource(ConfigurationSource configurationSource)
     => _principalEndConfigurationSource = configurationSource.Max(_principalEndConfigurationSource);
Example #13
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual InternalRelationshipBuilder Apply(InternalRelationshipBuilder relationshipBuilder)
        {
            Check.NotNull(relationshipBuilder, nameof(relationshipBuilder));

            var foreignKey = relationshipBuilder.Metadata;

            var fkPropertyOnPrincipal = FindForeignKeyAttributeOnProperty(foreignKey.PrincipalEntityType, foreignKey.PrincipalToDependent?.Name);
            var fkPropertyOnDependent = FindForeignKeyAttributeOnProperty(foreignKey.DeclaringEntityType, foreignKey.DependentToPrincipal?.Name);

            if (!string.IsNullOrEmpty(fkPropertyOnDependent) &&
                !string.IsNullOrEmpty(fkPropertyOnPrincipal))
            {
                // TODO: Log Error that unable to determine principal end based on foreign key attributes on properties

                relationshipBuilder = SplitNavigationsToSeparateRelationships(relationshipBuilder);
                if (relationshipBuilder == null)
                {
                    return(null);
                }
                fkPropertyOnPrincipal = null;
            }

            var fkPropertiesOnPrincipalToDependent = FindCandidateDependentPropertiesThroughNavigation(relationshipBuilder, pointsToPrincipal: false);
            var fkPropertiesOnDependentToPrincipal = FindCandidateDependentPropertiesThroughNavigation(relationshipBuilder, pointsToPrincipal: true);

            if (fkPropertiesOnDependentToPrincipal != null &&
                fkPropertiesOnPrincipalToDependent != null)
            {
                // TODO: Log error that foreign key properties are on both navigations

                relationshipBuilder = SplitNavigationsToSeparateRelationships(relationshipBuilder);
                if (relationshipBuilder == null)
                {
                    return(null);
                }
                fkPropertiesOnPrincipalToDependent = null;
            }

            var fkPropertiesOnNavigation = fkPropertiesOnDependentToPrincipal ?? fkPropertiesOnPrincipalToDependent;
            var upgradePrincipalToDependentNavigationSource  = fkPropertiesOnPrincipalToDependent != null;
            var upgradeDependentToPrincipalNavigationSource  = fkPropertiesOnDependentToPrincipal != null;
            ConfigurationSource?   invertConfigurationSource = null;
            IReadOnlyList <string> fkPropertiesToSet;

            if (fkPropertiesOnNavigation == null ||
                fkPropertiesOnNavigation.Count == 0)
            {
                if (fkPropertyOnDependent == null &&
                    fkPropertyOnPrincipal == null)
                {
                    return(relationshipBuilder);
                }
                if (fkPropertyOnDependent != null)
                {
                    fkPropertiesToSet = new List <string> {
                        fkPropertyOnDependent
                    };
                    upgradeDependentToPrincipalNavigationSource = true;
                }
                else
                {
                    invertConfigurationSource = ConfigurationSource.DataAnnotation;
                    fkPropertiesToSet         = new List <string> {
                        fkPropertyOnPrincipal
                    };
                    upgradePrincipalToDependentNavigationSource = true;
                }
            }
            else
            {
                fkPropertiesToSet = fkPropertiesOnNavigation;
                if (fkPropertyOnDependent == null &&
                    fkPropertyOnPrincipal == null)
                {
                    if (fkPropertiesOnPrincipalToDependent != null &&
                        foreignKey.IsUnique)
                    {
                        invertConfigurationSource = ConfigurationSource.DataAnnotation;
                    }
                }
                else
                {
                    if (fkPropertiesOnNavigation.Count != 1 ||
                        !string.Equals(fkPropertiesOnNavigation.First(), fkPropertyOnDependent ?? fkPropertyOnPrincipal))
                    {
                        // TODO: Log error that mismatch in foreignKey Attribute on navigation and property

                        relationshipBuilder = SplitNavigationsToSeparateRelationships(relationshipBuilder);
                        if (relationshipBuilder == null)
                        {
                            return(null);
                        }

                        fkPropertiesToSet = fkPropertiesOnDependentToPrincipal ?? new List <string> {
                            fkPropertyOnDependent
                        };
                    }

                    if (fkPropertyOnDependent != null)
                    {
                        upgradeDependentToPrincipalNavigationSource = true;
                    }
                    else
                    {
                        invertConfigurationSource = ConfigurationSource.DataAnnotation;
                    }
                }
            }

            var newRelationshipBuilder = relationshipBuilder;

            if (upgradeDependentToPrincipalNavigationSource)
            {
                newRelationshipBuilder.Metadata.UpdateDependentToPrincipalConfigurationSource(ConfigurationSource.DataAnnotation);
            }
            if (upgradePrincipalToDependentNavigationSource)
            {
                newRelationshipBuilder.Metadata.UpdatePrincipalToDependentConfigurationSource(ConfigurationSource.DataAnnotation);
            }
            if (invertConfigurationSource != null)
            {
                newRelationshipBuilder = newRelationshipBuilder.RelatedEntityTypes(
                    foreignKey.DeclaringEntityType, foreignKey.PrincipalEntityType, invertConfigurationSource.Value);
            }

            return(newRelationshipBuilder?.HasForeignKey(fkPropertiesToSet, ConfigurationSource.DataAnnotation) ?? relationshipBuilder);
        }
Example #14
0
 private void UpdateIsConcurrencyTokenConfigurationSource(ConfigurationSource configurationSource)
     => _isConcurrencyTokenConfigurationSource = configurationSource.Max(_isConcurrencyTokenConfigurationSource);
Example #15
0
 private void UpdateIsReadOnlyAfterSaveConfigurationSource(ConfigurationSource configurationSource)
     => _isReadOnlyAfterSaveConfigurationSource = configurationSource.Max(_isReadOnlyAfterSaveConfigurationSource);
Example #16
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdatePrincipalKeyConfigurationSource(ConfigurationSource configurationSource)
 {
     _principalKeyConfigurationSource = configurationSource.Max(_principalKeyConfigurationSource);
     PrincipalKey.UpdateConfigurationSource(configurationSource);
 }
Example #17
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdateIsRequiredConfigurationSource(ConfigurationSource configurationSource)
     => _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource);
Example #18
0
 private void UpdateDeleteBehaviorConfigurationSource(ConfigurationSource configurationSource)
     => _deleteBehaviorConfigurationSource = configurationSource.Max(_deleteBehaviorConfigurationSource);
Example #19
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void SetIsRequiredConfigurationSource(ConfigurationSource? configurationSource)
     => _isRequiredConfigurationSource = configurationSource;
Example #20
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdatePrincipalToDependentConfigurationSource(ConfigurationSource? configurationSource)
     => _principalToDependentConfigurationSource = configurationSource.Max(_principalToDependentConfigurationSource);
Example #21
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdateDependentToPrincipalConfigurationSource(ConfigurationSource? configurationSource)
     => _dependentToPrincipalConfigurationSource = configurationSource.Max(_dependentToPrincipalConfigurationSource);
Example #22
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdateForeignKeyPropertiesConfigurationSource(ConfigurationSource configurationSource)
 {
     _foreignKeyPropertiesConfigurationSource = configurationSource.Max(_foreignKeyPropertiesConfigurationSource);
     foreach (var property in Properties)
     {
         property.UpdateConfigurationSource(configurationSource);
     }
 }
Example #23
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual void UpdateForeignKeyConfigurationSource(ConfigurationSource configurationSource)
 => _foreignKeyConfigurationSource = _foreignKeyConfigurationSource.Max(configurationSource);
Example #24
0
 private void UpdateValueGeneratedConfigurationSource(ConfigurationSource configurationSource)
     => _valueGeneratedConfigurationSource = configurationSource.Max(_valueGeneratedConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetValueGenerated(ValueGenerated?valueGenerated, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetValueGeneratedConfigurationSource()) ||
 Metadata.ValueGenerated == valueGenerated;
Example #26
0
 private void UpdateRequiresValueGeneratorConfigurationSource(ConfigurationSource configurationSource)
     => _requiresValueGeneratorConfigurationSource = configurationSource.Max(_requiresValueGeneratorConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetMaxLength(int?maxLength, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetMaxLengthConfigurationSource()) ||
 Metadata.GetMaxLength() == maxLength;
Example #28
0
 private void UpdateIsStoreGeneratedAlwaysConfigurationSource(ConfigurationSource configurationSource)
     => _isStoreGeneratedAlwaysConfigurationSource = configurationSource.Max(_isStoreGeneratedAlwaysConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetBeforeSave(PropertySaveBehavior?behavior, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetBeforeSaveBehaviorConfigurationSource()) ||
 Metadata.GetBeforeSaveBehavior() == behavior;
Example #30
0
 private void UpdateIsUniqueConfigurationSource(ConfigurationSource configurationSource)
     => _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetValueGenerator(
     Func <IProperty, IEntityType, ValueGenerator> factory, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetValueGeneratorFactoryConfigurationSource()) ||
 Metadata.GetValueGeneratorFactory() == factory;
 private bool Overrides(bool fromDataAnnotation, ConfigurationSource?configurationSource)
 => (fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention)
 .Overrides(configurationSource);
Example #33
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void SetPrincipalEndConfigurationSource(ConfigurationSource? configurationSource)
     => _principalEndConfigurationSource = configurationSource;
Example #34
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual void UpdateInverseConfigurationSource(ConfigurationSource configurationSource)
 => _inverseConfigurationSource = _inverseConfigurationSource.Max(configurationSource);
Example #35
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public virtual void UpdatePrincipalToDependentConfigurationSource(ConfigurationSource?configurationSource)
 => _principalToDependentConfigurationSource = configurationSource.Max(_principalToDependentConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetIsConcurrencyToken(bool?concurrencyToken, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetIsConcurrencyTokenConfigurationSource()) ||
 Metadata.IsConcurrencyToken == concurrencyToken;
Example #37
0
 /// <summary>
 ///     Returns a value indicating whether the new configuration source can override configuration set with the old configuration source.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-conventions">Model building conventions</see> for more information.
 /// </remarks>
 /// <param name="newConfigurationSource">The new configuration source.</param>
 /// <param name="oldConfigurationSource">The old configuration source.</param>
 /// <returns><see langword="true" /> if the new configuration source can override configuration set with the old configuration source.</returns>
 public static bool Overrides(this ConfigurationSource?newConfigurationSource, ConfigurationSource?oldConfigurationSource)
 => newConfigurationSource?.Overrides(oldConfigurationSource) ?? oldConfigurationSource == null;
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetIsUnicode(bool?unicode, ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetIsUnicodeConfigurationSource()) ||
 Metadata.IsUnicode() == unicode;
Example #39
0
 /// <summary>
 ///     Returns a value indicating whether the configuration source always takes precedence over the other configuration source.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-conventions">Model building conventions</see> for more information.
 /// </remarks>
 /// <param name="newConfigurationSource">The new configuration source.</param>
 /// <param name="oldConfigurationSource">The old configuration source.</param>
 /// <returns><see langword="true" /> if the configuration source always takes precedence over the other configuration source.</returns>
 public static bool OverridesStrictly(this ConfigurationSource newConfigurationSource, ConfigurationSource?oldConfigurationSource)
 => newConfigurationSource.Overrides(oldConfigurationSource) && newConfigurationSource != oldConfigurationSource;
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetAfterSave(PropertySaveBehavior?behavior, ConfigurationSource?configurationSource)
 => (configurationSource.Overrides(Metadata.GetAfterSaveBehaviorConfigurationSource()) &&
     (behavior == null ||
      Metadata.CheckAfterSaveBehavior(behavior.Value) == null)) ||
 Metadata.GetAfterSaveBehavior() == behavior;
Example #41
0
 /// <summary>
 ///     Returns a value indicating whether the configuration source always takes precedence over the other configuration source.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-conventions">Model building conventions</see> for more information.
 /// </remarks>
 /// <param name="newConfigurationSource">The new configuration source.</param>
 /// <param name="oldConfigurationSource">The old configuration source.</param>
 /// <returns><see langword="true" /> if the configuration source always takes precedence over the other configuration source.</returns>
 public static bool OverridesStrictly(this ConfigurationSource?newConfigurationSource, ConfigurationSource?oldConfigurationSource)
 => newConfigurationSource.HasValue && newConfigurationSource.Value.OverridesStrictly(oldConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetConversion(
     [CanBeNull] ValueConverter converter, ConfigurationSource?configurationSource)
 => (configurationSource.Overrides(Metadata.GetValueConverterConfigurationSource()) &&
     Metadata.CheckValueConverter(converter) == null) ||
 Metadata.GetValueConverter() == converter;
Example #43
0
 public static ConfigurationSource?Max(this ConfigurationSource?left, ConfigurationSource?right)
 => left.Overrides(right)
         ? left
         : right;
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetStructuralValueComparer([CanBeNull] ValueComparer comparer, ConfigurationSource?configurationSource)
 => (configurationSource.Overrides(Metadata.GetStructuralValueComparerConfigurationSource()) &&
     Metadata.CheckValueComparer(comparer) == null) ||
 Metadata.GetStructuralValueComparer() == comparer;
Example #45
0
 private void UpdateIsNullableConfigurationSource(ConfigurationSource configurationSource)
     => _isNullableConfigurationSource = configurationSource.Max(_isNullableConfigurationSource);
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public virtual bool CanSetPropertyAccessMode(
     PropertyAccessMode?propertyAccessMode,
     ConfigurationSource?configurationSource)
 => configurationSource.Overrides(Metadata.GetPropertyAccessModeConfigurationSource()) ||
 ((IReadOnlyPropertyBase)Metadata).GetPropertyAccessMode() == propertyAccessMode;
Example #47
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public virtual void SetValueGenerated(ValueGenerated? valueGenerated, ConfigurationSource configurationSource)
        {
            _flags &= ~(int)PropertyFlags.ValueGenerated;

            if (valueGenerated == null)
            {
                _valueGeneratedConfigurationSource = null;
            }
            else
            {
                _flags |= ((int)valueGenerated + 1) << 8;
                UpdateValueGeneratedConfigurationSource(configurationSource);
            }
        }