Bug #108926 .Net 6 support LongBlob with Entity Framework is limited to smal size
Submitted: 29 Oct 2022 9:12 Modified: 13 Jun 2023 6:20
Reporter: volkhard vogeler Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.31 OS:Windows
Assigned to: CPU Architecture:Any

[29 Oct 2022 9:12] volkhard vogeler
Description:
i´m using following packages:
This Project is using the following packages:
- Microsoft.EntityFrameworkCore 6.0.10
- MySql.Data 8.0.31
- MySql.EntityFrameworkCore 6.0.7

LongBlobs with big sizes like 50000 bytes are note stored in database

How to repeat:
Hello,

given is following .Net Core 6.0 C#-Program `

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Common;
using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using MySql.EntityFrameworkCore.Extensions;

namespace ConsoleApp1
{
class Blob
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
[Column(TypeName = "LongBlob")]
public byte[] Data { get; set; }
}

class AppContext : DbContext
{
public DbSet<Blob> Blobs { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySQL("server=localhost;database=testblob;user=xyz;password=xyz");
}
}

internal class Program
{

static void Main(string[] args)
{
insert();
read();
}

private static void insert()
{
using (AppContext ctx = new AppContext())
{
ctx.Database.EnsureCreated();
int blobsize = 50;
byte[] bytes = null;
bytes = new byte[blobsize];
for (int i = 0; i < bytes.Length; i++)
{
bytes = Convert.ToByte(i % 256);
}

Blob one = new Blob {Data = bytes, Name = "Hello"};
ctx.Blobs.Add(one);
ctx.SaveChanges();
}
}

private static void read()
{
using (AppContext ctx = new AppContext())
{
foreach (Blob blob in ctx.Blobs)
{
Console.WriteLine($"{blob.Id}={blob.Data.Length}");
}
}
}
}
}
`

This Project is using the following packages:
- Microsoft.EntityFrameworkCore 6.0.10
- MySql.Data 8.0.31
- MySql.EntityFrameworkCore 6.0.7

This program inserts data to a table "Blobs" with some data inkl. a longblob column and reads in a second step that data and also writes the blob-size to the console

Starting this program is working fine. But when i set blobsize higher (e.g. 50000) then the blobsize is 0.
[15 Nov 2022 12:54] MySQL Verification Team
Hello volkhard vogeler,

Thank you for the bug report.
Verified as described.

Regards,
Ashwini Patil
[12 Feb 2023 17:39] volkhard vogeler
Hello,
do you know when there will be a bugfix?
This also occurs with
- Microsoft.EntityFrameworkCore 7.0.2
- MySql.Data 8.0.32
- MySql.EntityFrameworkCore 7.0.0

best regards

Volkhard
[13 Jun 2023 6:20] volkhard vogeler
Hello,
is there any Bugfix planned for this. 
Other urgant Updates on Libraries are blocked by this bug.

best regards
Volkhard
[30 Jan 18:54] Philip Zubaly
Migrating an existing application to .NET 8 and EF Core 8. An eneity with a longblob column in it returns an empty byte array. Does Mysql.EntityFrameworkCore support longblob coolumns?

- MySql.EntityFrameworkCore 8.0.0
- MySql.Data 8.3.0
[30 Jan 21:32] Philip Zubaly
Correction on my previous comment. The data is retrieved properly, but large data is not inserted, whereas small data is inserted. This is the same behavior described in this bug, but with the latest 8.3.0 Connector.
[31 Jan 15:18] Philip Zubaly
Using Volkhard's provided code I have found that the limit for inserts with the latest packages (Connector/NET 8.3.0 and Microsoft.EntityFrameworkCore 8.0.1) is 8000 bytes. Might there be an 8000 byte buffer in the code that is limiting the inserts?