/// <summary>
 ///     Returns a value indicating whether the given value can be set as the 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="propertyBuilder">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><see langword="true" /> if the given value can be set as the default value generation strategy.</returns>
 public static bool CanSetValueGenerationStrategy(
     this IConventionPropertyBuilder propertyBuilder,
     SqlServerValueGenerationStrategy?valueGenerationStrategy,
     bool fromDataAnnotation = false)
 => (valueGenerationStrategy == null ||
     SqlServerPropertyExtensions.IsCompatibleWithValueGeneration(propertyBuilder.Metadata)) &&
 propertyBuilder.CanSetAnnotation(
     SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation);
Example #2
0
        /// <summary>
        ///     Returns a value indicating whether the given value can be set as the value generation strategy.
        /// </summary>
        /// <param name="propertyBuilder"> 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> <c>true</c> if the given value can be set as the default value generation strategy. </returns>
        public static bool CanSetValueGenerationStrategy(
            [NotNull] this IConventionPropertyBuilder propertyBuilder,
            SqlServerValueGenerationStrategy?valueGenerationStrategy,
            bool fromDataAnnotation = false)
        {
            Check.NotNull(propertyBuilder, nameof(propertyBuilder));

            return((valueGenerationStrategy == null ||
                    SqlServerPropertyExtensions.IsCompatibleWithValueGeneration(propertyBuilder.Metadata)) &&
                   propertyBuilder.CanSetAnnotation(
                       SqlServerAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation));
        }