Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store images using Entity Framework Code First CTP 5?

I'm just trying to figure out if there is a simple way to store and retrieve binary (file) data using EF Code First CTP 5? I would really like it to use the FILESTREAM type, but I'm really just looking for some way to make it work.

like image 795
Max Schmeling Avatar asked Jan 11 '11 00:01

Max Schmeling


People also ask

How do I use code first in Entity Framework?

Step 1 − First, create the console application from File → New → Project… Step 2 − Select Windows from the left pane and Console Application from the template pane. Step 3 − Enter EFCodeFirstDemo as the name and select OK. Step 4 − Right-click on your project in the solution explorer and select Manage NuGet Packages…


1 Answers

I always create another class like ProductImage with a one-to-one association in order to manage lazy loading and also to normalize the table:

public class ProductImage {     public int ProductId { get; private set; }     public byte[] Image { get; set; } } 
like image 104
nima Avatar answered Sep 24 '22 06:09

nima