byte[]
should work just fine, but you can use the Linq.Binary
class also if you prefer. It represents an immutable block of bytes (byte[]
is mutable).
Using f.testVarbinary[0] = 123;
won't work for modifying a record's value because the entity is only tracking the property, testVarbinary
, not every element of the array. You can probably just mark the property as modified just by calling the property setter, as in:
f.testVarbinary = f.testVarbinary;
However, the standard way of doing this is:
DbEntityEntry<MyEntity> entry = context.Entry(f);
entry.Property(e => e.testVarbinary).IsModified = true;
Or to mark the entire entity as modified, use:
entry.State = EntityState.Modified;