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.