Saving an Image Using the CodeFirst Entity Structure

I am new to entity structure and I am trying to move on to the first Code approach. When defining one of my model classes, I want one of the class objects to map to the Image column in my Sql Server database. What type of object would I use here so that when I create the table, it makes the column a column of "Image"?

+4
source share
1 answer

you can use the byte [] data type for your objects, for Sql you can use varbinary (max) (since the image data type will be removed from a future version of sql. MSDN - Image data type

public byte[] yourFiles{get;set;} 

you can configure it using free api

 modelBuilder.Entity<SomePOCOClass>().Property(p => p.yourFiles).HasColumnName("yourColumnName").HasMaxLength(SomeLength).HasColumnType("varbinary"); 
+7
source

Source: https://habr.com/ru/post/1394783/


All Articles