Save file to SQL Server 2008 database using Entity Framework

How to save a file in a SQL Server 2008 database using Entity Framework?

I want to use FileStream in SQL Server 2008.

+3
source share
2 answers

I don’t understand why this will not work - the columns filestreamare only displayed as varbinary(MAX), so you can set the column using Entity Framework:

An example is here :

Files newFile = new Files();
newFile.FileID = Guid.NewGuid();
newFile.FileContents = System.IO.File.ReadAllBytes("TextFile1.txt");
ctx.AddObject("Files", newFile);
ctx.SaveChanges();
+7
source

Entity infrastructure does not support specific SQL server features such as filestream. You cannot do this with EF, you must return to ADO.NET.

Edit:

Undeleting , , EF FILESTREAM. EF FILESTREAM, , @BrokenGlass . , EF FILESTREAM FILESTREAM. .

+5

All Articles