Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework 4: Image type?

I am creating an Entity Data Model for a document. I want to store the body of the document as a BLOB--document bodies will be larger than the varbinary max. As I understand things, what I need to do is create a property of type Image to store the document body.

Here's my problem: The types listed in the Properties pane do not include an Image type:

enter image description here

Does EF4 recognize an Image type? If so, how do I create an entity property of type Image? Thanks for your help.

like image 256
David Veeneman Avatar asked Feb 09 '26 15:02

David Veeneman


2 Answers

Image is deprecated, you should use varbinary(MAX) instead - but if you are using files larger than 2GB (as you apparently are since varbinary(MAX) would otherwise be sufficient) you probably should bypass this altogether and save them on disk - with plain SQL Server 2008 I'd suggest a filestream.

According to this article this approach will also work for Entity Framework (although the article refers to an older EF version and I haven't tried it personally)

like image 113
BrokenGlass Avatar answered Feb 13 '26 23:02

BrokenGlass


varbinary(max) is replacement of Image type. The storage size of varbinary(max) is 2^31 - 1 Bytes => 2GB. it should be enough. Image type is deprecated and will be probably removed in future version of SQL server. Use Binary type for your data and set its length to Max.

Btw. working with such amount of data in EF can be quite bad idea.

like image 22
Ladislav Mrnka Avatar answered Feb 13 '26 21:02

Ladislav Mrnka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!