Repository: dotnet/efcore
File: src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs (C#)

Code before:
    }

    private readonly bool _isJsonTypeSupported = sqlServerSingletonOptions.SupportsJsonType;

    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
        => base.FindMapping(mappingInfo)
            ?? FindRawMapping(mappingInfo)?.WithTypeMappingInfo(mappingInfo);

    private RelationalTypeMapping? FindRawMapping(RelationalTypeMappingInfo mappingInfo)
    {
        var clrType = mappingInfo.ClrType;
        var storeTypeName = mappingInfo.StoreTypeName;

        if (clrType == typeof(JsonTypePlaceholder))
        {
            // We get here when a structural type (complex type or owned entity) is mapped to JSON.
            return mappingInfo.StoreTypeNameBase switch
            {
                "json" => SqlServerStructuralJsonTypeMapping.JsonTypeDefault,
                "nvarchar" => SqlServerStructuralJsonTypeMapping.NvarcharMaxDefault,

                null when _isJsonTypeSupported => SqlServerStructuralJsonTypeMapping.JsonTypeDefault,
                null => SqlServerStructuralJsonTypeMapping.NvarcharMaxDefault,

                _ => null
            };
        }

        if (storeTypeName != null)
        {
            var storeTypeNameBase = mappingInfo.StoreTypeNameBase;
            if (storeTypeNameBase!.StartsWith("[", StringComparison.Ordinal)
                && storeTypeNameBase.EndsWith("]", StringComparison.Ordinal))
            {
                storeTypeNameBase = storeTypeNameBase[1..^1];
            }

            if (clrType == typeof(float)
                && mappingInfo.Precision is <= 24
                && (storeTypeNameBase.Equals("float", StringComparison.OrdinalIgnoreCase)
                    || storeTypeNameBase.Equals("double precision", StringComparison.OrdinalIgnoreCase)))
            {
                return SqlServerFloatTypeMapping.Default;
            }


Review comment (suggestion):
If it's not `nvarchar(max)` you'd need to create a new mapping with the specified length as it's done for strings below

Code after:
    }

    private readonly bool _isJsonTypeSupported = sqlServerSingletonOptions.SupportsJsonType;

    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo)
        => base.FindMapping(mappingInfo)
            ?? FindRawMapping(mappingInfo)?.WithTypeMappingInfo(mappingInfo);

    private RelationalTypeMapping? FindRawMapping(RelationalTypeMappingInfo mappingInfo)
    {
        var clrType = mappingInfo.ClrType;
        var storeTypeName = mappingInfo.StoreTypeName;

        if (clrType == typeof(JsonTypePlaceholder))
        {
            // We get here when a structural type (complex type or owned entity) is mapped to JSON.
            return mappingInfo.StoreTypeNameBase switch
            {
                "json" => SqlServerStructuralJsonTypeMapping.JsonTypeDefault,

                // Note that if the store type is non-max (e.g. nvarchar(2000)), it gets cloned outside for the right size.
                "nvarchar" => SqlServerStructuralJsonTypeMapping.NvarcharMaxDefault,

                null when _isJsonTypeSupported => SqlServerStructuralJsonTypeMapping.JsonTypeDefault,
                null => SqlServerStructuralJsonTypeMapping.NvarcharMaxDefault,

                _ => null
            };
        }

        if (storeTypeName != null)
        {
            var storeTypeNameBase = mappingInfo.StoreTypeNameBase;
            if (storeTypeNameBase!.StartsWith("[", StringComparison.Ordinal)
                && storeTypeNameBase.EndsWith("]", StringComparison.Ordinal))
            {
                storeTypeNameBase = storeTypeNameBase[1..^1];
            }

            if (clrType == typeof(float)
                && mappingInfo.Precision is <= 24
                && (storeTypeNameBase.Equals("float", StringComparison.OrdinalIgnoreCase)
                    || storeTypeNameBase.Equals("double precision", StringComparison.OrdinalIgnoreCase)))
            {
                return SqlServerFloatTypeMapping.Default;