-1

There seem to be a good number of questions related to this, but I haven't found a solution to the problem yet. I apologize if the answer is here and I just haven't found it.

I'm trying to create a Web API project that gives me the middle layer between an HTML page for uploading a file and SQL database that stores the files. I know it's generally a bad approach to store files in the database, but I'm trying make a smaller test app that will help me diagnose a bigger problem in an existing database that I can't change.

I can set up a controller with a path like "api/docs/save" just fine, but saving the file in the database has become something of a nightmare. I can't seem to get a reference to "System.Data" or "System.Data.SqlClient" to work in the project. I've tried the NuGet packages with no luck. I even tried just making a class library using normal C# .NET, but adding a reference to that class library doesn't work either.

How do I set up a Web API project so I can use the data base access methods I'm used to?

As a side note: I don't have access to the existing front end code for the app, so I can't just add a test page there. I need to create something I can run locally through Visual Studio.

Kevin
  • 175
  • 8
  • `Project` -> `Add Reference...` or, please come back and provide us with the *exact error message, in detail* as you are seeing it. Please also consider reading [ask] and provide a full [mcve] if available. – gravity Aug 14 '17 at 17:58
  • Add Reference doesn't have System.Data or System.Data.SqlClient as options in this project type. What I've read suggests that for Web API you need to use the NuGet packages. There is no error message... the references simply don't exist, and the NuGet Packages when installed don't allow me to put in a working "using System.Data.SqlClient". – Kevin Aug 14 '17 at 20:29
  • If I go to `Tools` -> `NuGet Package Manager` -> `Manage NuGet Packages for Solution`, then click on `Browse` up in the left, and type in `SqlClient` it's literally the first option. Click on it, check the box on the right (for your project) and hit 'Install' – gravity Aug 14 '17 at 20:32
  • I have already installed the NuGet packages. The problem is that they don't seem to install correctly. When I then add them to a cs file with the "using" directive, the IDE doesn't recognize the "System.Data" namespace. – Kevin Aug 15 '17 at 12:59

1 Answers1

1

I can replicate your problem in VS 2017 using Core 1.1 and there does seem to be a problem.

After installing the NuGet package save and reload the project and it should be fine.