简体   繁体   中英

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

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"?

我使用Pomelo.EntityFrameworkCore.MySql来解决我的问题。

In your OnModelCreating do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM