Reputation: 1832
By default c# data type byte[] in POCO object is mapped to sql type varbinary. Is it possible to map it to binary type using dataannotations or fluent API?
Thanx.
Upvotes: 2
Views: 2193
Reputation: 1832
I have found the answer myself. It can be done using Fluent API the following way
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<MyEntity>().Property(x => x.BinaryProperty).HasMaxLength(LengthOfBinaryField).IsFixedLength();
}
Upvotes: 2