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 static void Attach(IConventionEntityType entityType, IConventionCheckConstraint detachedCheckConstraint)
        {
            var newCheckConstraint = new CheckConstraint(
                (IMutableEntityType)entityType,
                detachedCheckConstraint.ModelName,
                detachedCheckConstraint.Sql,
                detachedCheckConstraint.GetConfigurationSource());

            Attach(detachedCheckConstraint, newCheckConstraint);
        }
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 static void Attach(IConventionCheckConstraint detachedCheckConstraint, IConventionCheckConstraint existingCheckConstraint)
        {
            var nameConfigurationSource = detachedCheckConstraint.GetNameConfigurationSource();

            if (nameConfigurationSource != null)
            {
                ((InternalCheckConstraintBuilder)existingCheckConstraint.Builder).HasName(
                    detachedCheckConstraint.Name, nameConfigurationSource.Value);
            }
        }
    private static bool AreCompatible(IConventionCheckConstraint checkConstraint, IConventionCheckConstraint baseCheckConstraint)
    {
        var baseTable = StoreObjectIdentifier.Create(baseCheckConstraint.EntityType, StoreObjectType.Table);

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

        if (checkConstraint.GetName(baseTable.Value) != baseCheckConstraint.GetName(baseTable.Value) &&
            checkConstraint.GetNameConfigurationSource() is ConfigurationSource nameConfigurationSource &&
            !nameConfigurationSource.OverridesStrictly(baseCheckConstraint.GetNameConfigurationSource()))
        {
            return(false);
        }

        return(CheckConstraint.AreCompatible(
                   checkConstraint,
                   baseCheckConstraint,
                   baseTable.Value,
                   shouldThrow: false));
    }