Search code examples
c#entity-frameworkentity-framework-4.1

Entity Framework 4.1 and BLOBs


I'm trying to work out what the best way to work with BLOBs and entity framework.

I am working with EF 4.1, and using POCO's/DbContext

So here's and example table:

MyTable
Key int
SomeFields ...
ABlob  (ok, it's actually a Text, but whatever)

Now, sometimes when I select from MyTable, I want to include the BLOB field, but a lot of the time, I don't.

Also, sometimes, when I update MyTable, I want to update the BLOB. but a lot of the time, I don't.

I could use anonymous types for the select operation, but I cannot seem to find a way to make this work at all for updates (I can't have 2 different classes in the same context mapped to the same table, if I try to use inheritance, I get a runtime error because EF is expecting a discriminator column).

Surely using EF doesn't mean that I always have to query all of my BLOBs. What am I missing here?


Solution

  • This could be done using Table Splitting. EF 4.1 and EF 4.