-3

I've got a C# program that I've been writing. I am able to connect directly to a MySQL instance fine and am storing a variety of data without issue. I have a file as part of the model that I'm trying to upload but it would appear that if it's above a certain size it doesn't store as anything. Here is the output of the class just before being saved: enter image description here

This is the variable within the class: public byte[] File { get; set; }

Here is the output of the MySQL Select OCTET_LENGTH(File) just after the savechanges.enter image description here. As you can see from this I have been able to save some stuff but not anything too large. Here is the output from MySQL Workbench showing the column has been defined as a "longblob":enter image description here

Any help on this would be amazing as I'm stumped as to what's going on.

I've tried changing the file type to MySqlDbType.Blob but at the moment .Blob isn't being recoginsed, I'm using the MySql.Data and MySql.EntityFrameworkCore nuget packages at the moment.

1

1 Answer 1

1

I figured this one out, in the end, I tried creating a OnModelCreating as below:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<MainTable>()
        .Property(b => b.File).HasColumnType("longblob");
}

However, that didn't resolve the issue as long and medium blobs weren't implemented correctly with MySql.EntityFrameworkCore 6.0.12 SDK. In the end, I installed the Pomelo.EntityFrameworkCore SDK and changed the connection object to it and it just worked straight away.

Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.