7

I'm in the process of upgrading an existing application to .NET Core (DNX SDK 1.0.0-rc1-update2) that uses SQL Servers FILESTREAM feature for reading/writing large BLOBs to the database. It uses the SqlFileStream class to achieve this however it doesn't appear to be available in .NET Core. Here are my references in project.json:

"frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.Runtime": "4.0.10.0",
        "System.Collections": "4.0.0.0"
      }
    },
    "dotnet5.4": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Data.Common": "4.0.1-beta-23516",
        "System.Data.SqlClient": "4.0.0-rc2-23623",
        "System.Collections": "4.0.11-beta-23516",
        "System.IO.FileSystem": "4.0.1-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
}

I've tried searching SO and Google, both of which have absolutely nothing on the subject.

Can someone please confirm if its actually unavailable or if its in another package I'm unaware of?

lawst
  • 498
  • 3
  • 12
  • Have you tried looking on nuget? A lot of functionality in .net core seems to come from nuget. – Simon Apr 25 '16 at 09:33
  • Yes I've tried a couple of different packages but none of them have panned out unfortunately – lawst Apr 25 '16 at 10:05
  • I'm also looking for this, but it is still unsuppoerted I believe. – Marcin Aug 22 '16 at 15:48
  • It is just around the corner. Take a look at my [answer](https://stackoverflow.com/a/57918703/4949005) in a similiar question – smoksnes Sep 13 '19 at 07:00
  • Possible duplicate of [Using SQL Server Filestream in .Net core 2](https://stackoverflow.com/questions/48372491/using-sql-server-filestream-in-net-core-2) – smoksnes Sep 13 '19 at 07:12

2 Answers2

3

I realize the question is old, but I just came across the issue - implementing SqlFileStream - listed on the github repo for CoreFX (.NET Core foundational libraries) and thought I'd mention it here. Here's a link to the issue, for reference: https://github.com/dotnet/corefx/issues/15652

To recap: The issue is implementing SqlFileStream. It's currently an open issue, but not on the horizon anytime soon. One of the contributors states "if there are any Windows specific dependencies, we may not bring it in Core."

SWalters
  • 3,615
  • 5
  • 30
  • 37
1

I've actually been interested in this for a while and have taken some time over the last few days.

Unfortunately, FILESTREAM uses several NTFS and NT specific system calls (NtCreateFile, DeviceIoControl in particular, but a few others to support those as well) to manage access to the file. Also, unfortunately, as of this writing the latest MSSQL CTPs for Linux don't support FILESTREAM, and there's little clarity as to whether that's on the roadmap or where it might be (strangely, you can restore a database that supports FILESTREAM but FileTable doesn't seem to be supported).

There are two problems here: it's not clear that replacing the NT specific APIs would respect transactional integrity (or even work at all), and it's not clear that they could ever work from a non-Windows environment anyway. Because of these facts, I don't see SqlFileStream being supported any time in the near future for core.

There is some precedent for Windows Only type of low level, for example in System.Net.Socket.IOControl. SqlFileStream could perhaps take a similar path. Alternatively, it might be possible to build a specific SqlFileStream NuGet package, but have it only be supported/runnable on Windows. I'm not sure how valuable this would be though - if you're going to P/Invoke in a Windows only way to begin with, why not just P/Invoke to a .NET 4.6.x dll?

Cross posting this to the github issue: https://github.com/dotnet/corefx/issues/15652

Edit: As an alternative to P/Invoke, you could certainly create some other kind of service (RESTful, WCF, some other pipe or TCP or even memory mapped file) in .NET 4.x for a .NET Core library or application to access.

Dan Field
  • 20,885
  • 5
  • 55
  • 71