1

I am currently working on a project that needs to store about 5x2mb files for each user in the system. There will eventually be tens of thousands of users. I'm using ASP.NET MVC5, EF6 code-first.

I've read about using Filestream, so that I don't pollute the database with a lot of files. But I can't find any samples as to how I would write my code-first entity to use this type.

Any sample or alternative solution is much appreciated!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kristian Nissen
  • 1,153
  • 2
  • 11
  • 29
  • EF doesn't directly integrate with `FILESREAM` - to EF. In order to use the benefits of `FILESTREAM`, you need to look at the [SqlFileStream](http://msdn.microsoft.com/en-us/library/system.data.sqltypes.sqlfilestream%28v=vs.110%29.aspx) class in raw ADO.NET - see also [Using SqlFileStream in C# to Access SQL Server FILESTREAM Data](http://lennilobel.wordpress.com/2011/08/22/using-sqlfilestream-in-c-to-access-sql-server-filestream-data/) – marc_s Aug 17 '14 at 11:46
  • 1
    I'm thinking about, just storing the pathname in the database and the file on disk. What is your take on this? – Kristian Nissen Aug 17 '14 at 13:50

1 Answers1

0

Best way to do this is to upload the files on a server and store the path of the files in your database. This is way more easier and faster. You have tons of tutorials and NuGet packages how to upload (multiple) files (at once) in MVC.

letsjak
  • 359
  • 3
  • 14