Repository: dotnet/efcore
File: src/EFCore.Relational/Extensions/RelationalOwnedNavigationBuilderExtensions.cs (C#)

Code before:
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore;

/// <summary>
///     Relational database specific extension methods for <see cref="OwnedNavigationBuilder" />.
/// </summary>
/// <remarks>
///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see> for more information and examples.
/// </remarks>
public static class RelationalOwnedNavigationBuilderExtensions
{
    /// <summary>
    ///     Configures a relationship where this entity type and the entities that it owns are mapped to a JSON column in the database.
    /// </summary>
    /// <remarks>
    ///     This method should only be specified for the outer-most owned entity in the given ownership structure.
    ///     All entities owned by this will be automatically mapped to the same JSON column.
    ///     The ownerships must still be explicitly defined.
    ///     Name of the navigation will be used as the JSON column name.
    /// </remarks>
    /// <param name="builder">The builder for the owned navigation being configured.</param>
    /// <returns>The same builder instance so that multiple calls can be chained.</returns>
    [Obsolete(
        "ToJson() on owned entities has been obsoleted, please switch to using complex types instead for mapping to JSON. See https://aka.ms/efcore-docs-json-owned-entities for more information.",
        DiagnosticId = "EF8001")]
    public static OwnedNavigationBuilder ToJson(this OwnedNavigationBuilder builder)
        => builder.ToJson(builder.Metadata.GetNavigation(pointsToPrincipal: false)!.Name);

    /// <summary>
    ///     Configures a relationship where this entity type and the entities that it owns are mapped to a JSON column in the database.
    /// </summary>
    /// <remarks>
    ///     This method should only be specified for the outer-most owned entity in the given ownership structure.
    ///     All entities owned by this will be automatically mapped to the same JSON column.
    ///     The ownerships must still be explicitly defined.
    ///     Name of the navigation will be used as the JSON column name.
    /// </remarks>
    /// <param name="builder">The builder for the owned navigation being configured.</param>
    /// <returns>The same builder instance so that multiple calls can be chained.</returns>
    [Obsolete(
        "ToJson() on owned entities has been obsoleted, please switch to using complex types instead for mapping to JSON. See https://aka.ms/efcore-docs-json-owned-entities for more information.",
        DiagnosticId = "EF8001")]
    public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwnerEntity, TDependentEntity>(
        this OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> builder)
        where TOwnerEntity : class
        where TDependentEntity : class
        => (OwnedNavigationBuilder<TOwnerEntity, TDependentEntity>)((OwnedNavigationBuilder)builder).ToJson();

    /// <summary>

Review comment (suggestion):
Also link to an issue to provide feedback. Could be https://github.com/dotnet/efcore/issues/37290 or another one

Code after:
﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore;

/// <summary>
///     Relational database specific extension methods for <see cref="OwnedNavigationBuilder" />.
/// </summary>
/// <remarks>
///     See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see> for more information and examples.
/// </remarks>
public static class RelationalOwnedNavigationBuilderExtensions
{
    /// <summary>
    ///     Configures a relationship where this entity type and the entities that it owns are mapped to a JSON column in the database.
    /// </summary>
    /// <remarks>
    ///     This method should only be specified for the outer-most owned entity in the given ownership structure.
    ///     All entities owned by this will be automatically mapped to the same JSON column.
    ///     The ownerships must still be explicitly defined.
    ///     Name of the navigation will be used as the JSON column name.
    /// </remarks>
    /// <param name="builder">The builder for the owned navigation being configured.</param>
    /// <returns>The same builder instance so that multiple calls can be chained.</returns>
    [Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
    public static OwnedNavigationBuilder ToJson(this OwnedNavigationBuilder builder)
        => builder.ToJson(builder.Metadata.GetNavigation(pointsToPrincipal: false)!.Name);

    /// <summary>
    ///     Configures a relationship where this entity type and the entities that it owns are mapped to a JSON column in the database.
    /// </summary>
    /// <remarks>
    ///     This method should only be specified for the outer-most owned entity in the given ownership structure.
    ///     All entities owned by this will be automatically mapped to the same JSON column.
    ///     The ownerships must still be explicitly defined.
    ///     Name of the navigation will be used as the JSON column name.
    /// </remarks>
    /// <param name="builder">The builder for the owned navigation being configured.</param>
    /// <returns>The same builder instance so that multiple calls can be chained.</returns>
    [Obsolete(EFDiagnostics.OwnedJsonObsoleteMessage, DiagnosticId = EFDiagnostics.OwnedJsonObsolete)]
    public static OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> ToJson<TOwnerEntity, TDependentEntity>(
        this OwnedNavigationBuilder<TOwnerEntity, TDependentEntity> builder)
        where TOwnerEntity : class
        where TDependentEntity : class
        => (OwnedNavigationBuilder<TOwnerEntity, TDependentEntity>)((OwnedNavigationBuilder)builder).ToJson();

    /// <summary>
    ///     Configures a relationship where this entity type and the entities that it owns are mapped to a JSON column in the database.
    /// </summary>
    /// <remarks>
    ///     This method should only be specified for the outer-most owned entity in the given ownership structure.