Store files in database using Entity Framework Core

后端 未结 3 2478
-上瘾入骨i
-上瘾入骨i 2021-02-19 22:45

How to store files in a SQL Server database using Entity Framework Core (Code-First) in an ASP.NET Core app?

I have tried using Filestream but unfortunately

3条回答
  •  囚心锁ツ
    2021-02-19 23:25

    I am assuming that you are trying to use the windows filestream for sql server, which is not yet supported by .NET Core. You have to store the file as a byte array as already said (which will convert to varbinary(max) in sql server) and copy the file content over when uploading using a memory-stream for instance.

提交回复
热议问题