I am new to entity framework and I am trying to go the Code First approach. When defining one of my model classes I want one of the objects in the class to map to a Image column in my Sql Server Database. What object type would I use here so that when the table is created it would make that column an Image column?
1 Answer
you can use byte[] datatype on your objects, for Sql you can use varbinary(max) (as image data type will be removed from future sql version. MSDN - Image datatype
public byte[] yourFiles{get;set;}
you can configure like this using fluent api
modelBuilder.Entity<SomePOCOClass>().Property(p => p.yourFiles).HasColumnName("yourColumnName").HasMaxLength(SomeLength).HasColumnType("varbinary");
2 Comments
esastincy
Will that create an Image column?
Ravi Gadag
@esastincy check uodated ans.