none
Entity framework Code First Binary or Image field in SQL Server RRS feed

  • Question

  • Hello,

    We are beggining to use EF-Code first, and this still hasn't been resolved.The way EF-Code first stores binary inside SQL server, using an nvar declaration, doesnt take advantage of the server's capabilities of storing the file directly to disk.

    Since Code first automatically generates DB objects, we don't want to intervent the process by manually altering the table (which could also cause troubles with mapping etc).

    So, is there a way to store binary data properly on SQL server? Maybe a custom library somewhere that adds a special attribute for SQL server environments?

    Thursday, March 15, 2012 9:07 AM

Answers

  • Because EF is supposed to be Database agnostic and the FILESTREAM feature is specific to SQL Server 2008 I wouldn't expect to see this any time soon.  It'd be nice though.
    Friday, March 16, 2012 10:51 AM

All replies

  • Because EF is supposed to be Database agnostic and the FILESTREAM feature is specific to SQL Server 2008 I wouldn't expect to see this any time soon.  It'd be nice though.
    Friday, March 16, 2012 10:51 AM
  • Hi Mihalis-GR,

    Welcome to MSDN Forum.

    I agree with @TheDuke2k. You can't use SQL FILESTREAM in EF. EF is supposed to work on top of different database servers but filestream feature is specific feature of SQL 2008 and newer.  you can use FILESTREAM in the database but EF will not take advantage of streaming. It will load it as standard varbinary(max).

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 3:25 AM
    Moderator