How to store 'blob' type in MySQL with Entity Framework Core using byte[]?

entity-framework-core mysql

Question

I have code first model that looks like this:

public class Document
{
    [Key]   
    public int DocumentId {get;set;}

    [Required]
    public byte[] Blob {get; set;}
}

I want that to map to blob data type in MySQL but I keep getting varbinary(255)

How do I get it to map to "blob"?

1
6
12/20/2016 4:08:41 AM

Accepted Answer

I used Pomelo.EntityFrameworkCore.MySql to fix my problem.

1
3/25/2017 12:55:14 PM

Popular Answer

In your OnModelCreating do:

modelBuilder.Entity<Document>(entity =>
{
  entity.Property(x => x.Blob ).HasColumnType("blob");
}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow