4

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 1

7

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");
Sign up to request clarification or add additional context in comments.

2 Comments

Will that create an Image column?
@esastincy check uodated ans.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.