Exemplo n.º 1
0
        /// <summary>
        ///     Configures the explicit default collation for char-based <see cref="Guid"/> columns, which will be used by all appropriate
        ///     columns without an explicit collation.
        /// </summary>
        /// <param name="modelBuilder"> The model builder. </param>
        /// <param name="collation">
        ///     The <see cref="Guid"/> default collation to apply.
        ///     An empty string means that no explicit collation will be applied, while <see langword="null"/> means that the default
        ///     collation `ascii_general_ci` will be applied.
        /// </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,
        ///     <see langword="null" /> otherwise.
        /// </returns>
        public static IConventionModelBuilder UseGuidCollation(
            [NotNull] this IConventionModelBuilder modelBuilder,
            string collation,
            bool fromDataAnnotation = false)
        {
            if (modelBuilder.CanSetGuidCollation(collation, fromDataAnnotation))
            {
                modelBuilder.Metadata.SetGuidCollation(collation, fromDataAnnotation);
                return(modelBuilder);
            }

            return(null);
        }