Bug #113810 Entity Framework Core does not populate property for longblob column
Submitted: 30 Jan 19:55 Modified: 30 Jan 20:23
Reporter: Philip Zubaly Email Updates:
Status: Closed Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.3.0 OS:Windows
Assigned to: CPU Architecture:Any

[30 Jan 19:55] Philip Zubaly
Migrating a system from .NET 4.8 to .NET 8 and EF Core 8. 

When Entity Framework Core populates an entity from a table with a longblob column in it, the property populated from the longblob column in the database is an empty byte array even though there is data in the longlob column.

Appears to be similar to bug #108926 but with the latest versions of the Connector/NET

How to repeat:
Have a database table with a longlob column in it populated with data.
Use EF scaffolding to create a DBContext

Here is the model builder code we have generated:

modelBuilder.Entity<FileData>(entity =>
    entity.HasKey(e => e.FileDataSha1Hash).HasName("PRIMARY");
    entity.Property(e => e.FileDataSha1Hash)
    entity.Property(e => e.BinaryData)
    entity.Property(e => e.FileSize).HasColumnName("file_size");

Here is the corresponding FileData entity:

public partial class FileData
    public string FileDataSha1Hash { get; set; }
    public byte[] BinaryData { get; set; }
    public int FileSize { get; set; }

The longblob column is binary_data and the entity property is byte[] BinaryData.

When the context is queried for a FileData entity that has binary data, the entity is returned with all properties populated correctly except for the BinaryData property, which is byte[0]. Note that the sample that was queried for had a longblob column with 101,033 bytes of data, so it is larger than blob, but smaller than mediumblob.

Sample Linq query that returns the entity:

FileData matchingFileData = context.FileData.Find(hash);
[30 Jan 19:59] Philip Zubaly
The Connector (MySql.Data) version is 8.3.0, but the corresponding MySql.EntityFrameworkCore version is 8.0.0. We are using the latest Connector NET NuGet packages