/// <summary>
        ///     Returns a value indicating whether the given name and schema can be set for the hi-lo sequence.
        /// </summary>
        /// <remarks>
        ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
        ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
        ///     for more information.
        /// </remarks>
        /// <param name="modelBuilder">The model builder.</param>
        /// <param name="name">The name of the sequence.</param>
        /// <param name="schema">The schema of the sequence.</param>
        /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
        /// <returns><see langword="true" /> if the given name and schema can be set for the hi-lo sequence.</returns>
        public static bool CanSetHiLoSequence(
            this IConventionModelBuilder modelBuilder,
            string?name,
            string?schema,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(name, nameof(name));
            Check.NullButNotEmpty(schema, nameof(schema));

            return(modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.HiLoSequenceName, name, fromDataAnnotation) &&
                   modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.HiLoSequenceSchema, schema, fromDataAnnotation));
        }
Example #2
0
        /// <summary>
        ///     Returns a value indicating whether the given name and schema can be set for the hi-lo sequence.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="name"> The name of the sequence. </param>
        /// <param name="schema">The schema of the sequence. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given name and schema can be set for the hi-lo sequence. </returns>
        public static bool CanSetHiLoSequence(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string name,
            [CanBeNull] string schema,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullButNotEmpty(name, nameof(name));
            Check.NullButNotEmpty(schema, nameof(schema));

            return(modelBuilder.CanSetAnnotation(NpgsqlAnnotationNames.HiLoSequenceName, name, fromDataAnnotation) &&
                   modelBuilder.CanSetAnnotation(NpgsqlAnnotationNames.HiLoSequenceSchema, schema, fromDataAnnotation));
        }
Example #3
0
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the service tier of the database.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="serviceTier"> The expression for the service tier of the database. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the service tier of the database. </returns>
        public static bool CanSetServiceTierSql(
            [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string serviceTier, bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.ServiceTierSql, serviceTier, fromDataAnnotation));
        }
Example #4
0
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the maximum size of the database.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="maxSize"> The maximum size of the database. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the maximum size of the database. </returns>
        public static bool CanSetDatabaseMaxSize(
            [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string maxSize, bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, maxSize, fromDataAnnotation));
        }
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the default increment for SQL Server IDENTITY.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="increment"> The incremental value that is added to the identity value of the previous row that was loaded. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the default increment for SQL Server IDENTITY. </returns>
        public static bool CanSetIdentityColumnIncrement(
            [NotNull] this IConventionModelBuilder modelBuilder, int?increment, bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation));
        }
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the default seed for Jet IDENTITY.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="seed"> The value that is used for the very first row loaded into the table. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the seed for Jet IDENTITY. </returns>
        public static bool CanSetIdentityColumnSeed(
            [NotNull] this IConventionModelBuilder modelBuilder, int?seed, bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(JetAnnotationNames.IdentitySeed, seed, fromDataAnnotation));
        }
Example #7
0
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the performance level of the database.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="performanceLevel"> The performance level of the database expression. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the performance level of the database. </returns>
        public static bool CanSetPerformanceLevelSql(
            [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string performanceLevel, bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.PerformanceLevelSql, performanceLevel, fromDataAnnotation));
        }
Example #8
0
        /// <summary>
        ///     Returns a value indicating whether the given <see cref="Guid"/> default collation setting can be set.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="collation"> The <see cref="Guid"/> default collation setting. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given <see cref="Guid"/> default collation setting can be set. </returns>
        public static bool CanSetGuidCollation(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string collation,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(MySqlAnnotationNames.GuidCollation, collation, fromDataAnnotation));
        }
Example #9
0
        /// <summary>
        ///     Returns a value indicating whether the maximum length allowed for store identifiers can be set.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="length"> The value to set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the maximum length allowed for store identifiers can be set. </returns>
        public static bool CanSetMaxIdentifierLength(
            [NotNull] this IConventionModelBuilder modelBuilder,
            int?length,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(RelationalAnnotationNames.MaxIdentifierLength, length, fromDataAnnotation));
        }
Example #10
0
        /// <summary>
        ///     Returns a value indicating whether the given container name can be set as default.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="name"> The default container name. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given container name can be set as default. </returns>
        public static bool CanSetDefaultContainer(
            this IConventionModelBuilder modelBuilder,
            string?name,
            bool fromDataAnnotation = false)
        {
            Check.NullButNotEmpty(name, nameof(name));

            return(modelBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation));
        }
Example #11
0
        /// <summary>
        ///     Returns a value indicating whether the given collation delegation modes can be set.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="delegationModes"> The collation delegation modes. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given collation delegation modes can be set as default. </returns>
        public static bool CanSetCollationDelegation(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] DelegationModes?delegationModes,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullOrEnumValue(delegationModes, nameof(delegationModes));

            return(modelBuilder.CanSetAnnotation(MySqlAnnotationNames.CollationDelegation, delegationModes, fromDataAnnotation));
        }
Example #12
0
        /// <summary>
        ///     Returns a value indicating whether the given character set can be set as default.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="charSet"> The character set. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given character set can be set as default. </returns>
        public static bool CanSetCharSet(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string charSet,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullButNotEmpty(charSet, nameof(charSet));

            return(modelBuilder.CanSetAnnotation(MySqlAnnotationNames.CharSet, charSet, fromDataAnnotation));
        }
Example #13
0
        /// <summary>
        ///     Returns a value indicating whether the given container name can be set as default.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="name"> The default container name. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given container name can be set as default. </returns>
        public static bool ForCosmosCanSetDefaultContainer(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string name,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullButNotEmpty(name, nameof(name));

            return(modelBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation));
        }
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the default value generation strategy.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="valueGenerationStrategy"> The value generation strategy. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <c>true</c> if the given value can be set as the default value generation strategy. </returns>
        public static bool CanSetValueGenerationStrategy(
            [NotNull] this IConventionModelBuilder modelBuilder,
            SqlServerValueGenerationStrategy?valueGenerationStrategy,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));

            return(modelBuilder.CanSetAnnotation(
                       SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation));
        }
    public static bool CanSetDefaultColumnCollation(
        this IConventionModelBuilder modelBuilder,
        string?collation,
        bool fromDataAnnotation = false)
    {
        Check.NotNull(modelBuilder, nameof(modelBuilder));

        return(modelBuilder.CanSetAnnotation(
                   NpgsqlAnnotationNames.DefaultColumnCollation, collation, fromDataAnnotation));
    }
Example #16
0
        /// <summary>
        ///     Returns a value indicating whether the given collation can be set as default.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="collation"> The collation. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given collation can be set as default. </returns>
        public static bool CanSetCollation(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string collation,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullButNotEmpty(collation, nameof(collation));

            return(modelBuilder.CanSetAnnotation(RelationalAnnotationNames.Collation, collation, fromDataAnnotation));
        }
Example #17
0
        /// <summary>
        ///     Returns a value indicating whether the given schema can be set as default.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="schema"> The default schema. </param>
        /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
        /// <returns> <see langword="true" /> if the given schema can be set as default. </returns>
        public static bool CanSetDefaultSchema(
            [NotNull] this IConventionModelBuilder modelBuilder,
            [CanBeNull] string schema,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(modelBuilder, nameof(modelBuilder));
            Check.NullButNotEmpty(schema, nameof(schema));

            return(modelBuilder.CanSetAnnotation(RelationalAnnotationNames.DefaultSchema, schema, fromDataAnnotation));
        }
    /// <summary>
    ///     Returns a value indicating whether the given PostgreSQL extension can be registered in the model.
    /// </summary>
    /// <remarks>
    ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
    ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
    ///     for more information and examples.
    /// </remarks>
    /// <param name="modelBuilder">The model builder.</param>
    /// <param name="schema">The schema in which to create the extension.</param>
    /// <param name="name">The name of the extension to create.</param>
    /// <param name="version">The version of the extension.</param>
    /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
    /// <returns><see langword="true" /> if the given value can be set as the default increment for SQL Server IDENTITY.</returns>
    public static bool CanSetPostgresExtension(
        this IConventionModelBuilder modelBuilder,
        string?schema,
        string name,
        string?version          = null,
        bool fromDataAnnotation = false)
    {
        var annotationName = PostgresExtension.BuildAnnotationName(schema, name);

        return(modelBuilder.CanSetAnnotation(annotationName, $"{schema},{name},{version}", fromDataAnnotation));
    }
Example #19
0
 public static IConventionModelBuilder HasValueGenerationStrategy(this IConventionModelBuilder modelBuilder, FbValueGenerationStrategy?valueGenerationStrategy, bool fromDataAnnotation = false)
 {
     if (modelBuilder.CanSetAnnotation(FbAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation))
     {
         modelBuilder.Metadata.SetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation);
         if (valueGenerationStrategy != FbValueGenerationStrategy.IdentityColumn)
         {
         }
         if (valueGenerationStrategy != FbValueGenerationStrategy.SequenceTrigger)
         {
         }
         return(modelBuilder);
     }
     return(null);
 }
    /// <summary>
    /// Configures the value generation strategy for the key property, when targeting PostgreSQL.
    /// </summary>
    /// <param name="modelBuilder">The builder for the property being configured.</param>
    /// <param name="valueGenerationStrategy">The value generation strategy.</param>
    /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
    /// <returns>
    /// The same builder instance if the configuration was applied, <c>null</c> otherwise.
    /// </returns>
    public static IConventionModelBuilder?HasValueGenerationStrategy(
        this IConventionModelBuilder modelBuilder,
        NpgsqlValueGenerationStrategy?valueGenerationStrategy,
        bool fromDataAnnotation = false)
    {
        if (modelBuilder.CanSetAnnotation(
                NpgsqlAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation))
        {
            modelBuilder.Metadata.SetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation);
            if (valueGenerationStrategy != NpgsqlValueGenerationStrategy.SequenceHiLo)
            {
                modelBuilder.HasHiLoSequence(null, null, fromDataAnnotation);
            }

            return(modelBuilder);
        }

        return(null);
    }
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the default value generation strategy.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="valueGenerationStrategy">The value generation strategy.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the default value generation strategy.</returns>
 public static bool CanSetValueGenerationStrategy(
     this IConventionModelBuilder modelBuilder,
     SqlServerValueGenerationStrategy?valueGenerationStrategy,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(
     SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation);
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the service tier of the database.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="serviceTier">The expression for the service tier of the database.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the service tier of the database.</returns>
 public static bool CanSetServiceTierSql(
     this IConventionModelBuilder modelBuilder,
     string?serviceTier,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.ServiceTierSql, serviceTier, fromDataAnnotation);
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the performance level of the database.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="performanceLevel">The performance level of the database expression.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the performance level of the database.</returns>
 public static bool CanSetPerformanceLevelSql(
     this IConventionModelBuilder modelBuilder,
     string?performanceLevel,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.PerformanceLevelSql, performanceLevel, fromDataAnnotation);
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the default increment for SQL Server IDENTITY.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="increment">The incremental value that is added to the identity value of the previous row that was loaded.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the default increment for SQL Server IDENTITY.</returns>
 public static bool CanSetIdentityColumnIncrement(
     this IConventionModelBuilder modelBuilder,
     int?increment,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentityIncrement, increment, fromDataAnnotation);
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the default seed for SQL Server IDENTITY.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="seed">The value that is used for the very first row loaded into the table.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the seed for SQL Server IDENTITY.</returns>
 public static bool CanSetIdentityColumnSeed(
     this IConventionModelBuilder modelBuilder,
     long?seed,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.IdentitySeed, seed, fromDataAnnotation);
 /// <summary>
 ///     Returns a value indicating whether the given value can be set as the maximum size of the database.
 /// </summary>
 /// <remarks>
 ///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and
 ///     <see href="https://aka.ms/efcore-docs-sqlserver">Accessing SQL Server and SQL Azure databases with EF Core</see>
 ///     for more information.
 /// </remarks>
 /// <param name="modelBuilder">The model builder.</param>
 /// <param name="maxSize">The maximum size of the database.</param>
 /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
 /// <returns><see langword="true" /> if the given value can be set as the maximum size of the database.</returns>
 public static bool CanSetDatabaseMaxSize(
     this IConventionModelBuilder modelBuilder,
     string?maxSize,
     bool fromDataAnnotation = false)
 => modelBuilder.CanSetAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, maxSize, fromDataAnnotation);