My recommendation is that you create a separate object (for example, ImageBytes with identifier and bytes) specifically for the field containing bytes, and make it associated with the Image object (which has Id and MimeType). You can use the "Partition tables" function (in EDMX and in the first code), where you can map multiple objects in one database table. Then you can query for image objects, and EF will select only the columns you need from the database. You can access bytes through the relationships you define between Image and ImageBytes. You can then either download the download, or lazy download, or explicit download to receive images.
If you use data annotations, all you have to do is specify a table for both objects:
[Table("Image")] public class Image {} [Table("Image")] public class ImageBytes {}
With smooth API
modelBuilder.Entity<Image>() .HasRequired(e => e.Bytes) .WithRequiredPrincipal(); modelBuilder.Entity<Image>().ToTable("Image"); modelBuilder.Entity<ImageBytes>().ToTable("Image");
NTN Julie
source share