0

After looking at different posts and creating an entity framework code first model using

public byte[] Image { get; set; }

to store my image, I see that the largest size is 8000 bytes and its a varbinary(max)! That seems pretty small even if I modify the image before I store it. Are there any better data types in a db to use for storing images? I read FileStream is better but not sure. Any advice will help!

I've looked at storing the images on disk, but have decided that storing profile pics in a database will be ok because this site has just 1-3 pics per account and the total number of accounts will be however many people register. (probably not that many)

chuckd
  • 13,460
  • 29
  • 152
  • 331

2 Answers2

0

I actually think I misread the info on Sql Server varbinary(max). I thought the largest size was 8000 bytes when in fact it is 2^31 bytes. So I can store larger images in my db then originally thought!

chuckd
  • 13,460
  • 29
  • 152
  • 331
-1

I think byte[] is better. You can create new class to store images, it can be more efficient.

public class ProductImage
{
    public int ImageId { get; set; }
    [MaxLength]
    public byte[] Image { get; set; }
}
nevra
  • 418
  • 1
  • 7
  • 21
  • this will still create a datatype of varbinary(max) in the database, which is 8000 bytes...How is this any different then what I am doing? – chuckd Feb 11 '15 at 07:42
  • I try to say when you use same datatype, you can increase performance to load data, because varchar(max) is the better way to store image. @user1186050 – nevra Feb 11 '15 at 08:18