Exemple #1
0
        /// <summary>
        ///     Configures the property name that the entity is mapped to when stored as an embedded document.
        /// </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-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information.
        /// </remarks>
        /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param>
        /// <param name="name">The name of the parent property.</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 IConventionEntityTypeBuilder?ToJsonProperty(
            this IConventionEntityTypeBuilder entityTypeBuilder,
            string?name,
            bool fromDataAnnotation = false)
        {
            if (!entityTypeBuilder.CanSetJsonProperty(name, fromDataAnnotation))
            {
                return(null);
            }

            entityTypeBuilder.Metadata.SetContainingPropertyName(name, fromDataAnnotation);

            return(entityTypeBuilder);
        }