Example #1
0
        /// <summary>
        ///     Configures whether the key is clustered when targeting SQL Server.
        /// </summary>
        /// <param name="keyBuilder"> The builder for the key being configured. </param>
        /// <param name="clustered"> A value indicating whether the key is clustered. </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 IConventionKeyBuilder IsClustered(
            [NotNull] this IConventionKeyBuilder keyBuilder,
            bool?clustered,
            bool fromDataAnnotation = false)
        {
            if (keyBuilder.CanSetIsClustered(clustered, fromDataAnnotation))
            {
                keyBuilder.Metadata.SetIsClustered(clustered, fromDataAnnotation);
                return(keyBuilder);
            }

            return(null);
        }