Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

EF is truncating JSON columns to 65k on insert statements (no replies)

$
0
0
Getting this error on inserting data into mysql table containing json column:

MySql.Data.MySqlClient.MySqlException (0x80004005): Invalid JSON text: "Missing a closing quotation mark in string." at position 65534 in value for column 'PropertyEvents.ContentObject'.

Based on the following log message, it appears that the INSERT statement generated by EF is limiting the parameter size to 65K, but couldn´t understand why:

"Microsoft.EntityFrameworkCore.Database.Command:Error: Failed executing DbCommand (989ms) [Parameters=[@p0='?' (Size = 65535)], CommandType='Text', CommandTimeout='30']
INSERT INTO PropertyEvents (ContentObject) VALUES (@p0);
SELECT Id FROM PropertyEvents WHERE ROW_COUNT() = 1 AND Id=LAST_INSERT_ID();

This is the complete exception message:

MySql.Data.MySqlClient.MySqlException (0x80004005): Invalid JSON text: "Missing a closing quotation mark in string." at position 65534 in value for column 'PropertyEvents.ContentObject'.
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.d__17.MoveNext()

Steps to reproduce
Configure EF Core Code First with the following entity type:
public class PropertyEvent
{
private PropertyEvent()
{
}

public int Id { get; private set; }
public string ContentObject { get; private set; }
}
using this configuration:
sealed class PropertyEventMap : IEntityTypeConfiguration
{
public void Configure(EntityTypeBuilder builder)
{
builder.Property(p => p.ContentObject).IsRequired().HasColumnType("JSON");
}
}

and then converts a json object greater than 65 k into PropertyEvent.ContentObject property and tries to insert it into db using "context.SaveChangesAsync()"

Further technical details
EF Core version: EF Core (2.01)
Database Provider: MySql.Data.EntityFrameworkCore (6.10.5) / MySQL 5.7.17
Operating system: Win10 Pro 64 bits (version 1709 build 16299.248)
IDE: Visual Studio 2017 (15.4.2)

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>