Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to use SQLClient library in the ASP.net Core but cant seem to get it working. I found this article online advising how to setup but its not working for me:
http://blog.developers.ba/using-classic-ado-net-in-asp-net-vnext/
I have a simple console application package. My project.json looks like this:
"version": "1.0.0-*",
"description": "DBTest Console Application",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"compilationOptions": {
"emitEntryPoint": true
"dependencies": {
"System.Data.Common": "4.0.1-beta-23516",
"System.Data.SqlClient" : "4.0.0-beta-23516"
"commands": {
"DBTest": "DBTest"
"frameworks": {
"dnx451": { },
"dnxcore50": {
"dependencies": {
"Microsoft.CSharp": "4.0.1-beta-23516",
"System.Collections": "4.0.11-beta-23516",
"System.Console": "4.0.0-beta-23516",
"System.Linq": "4.0.1-beta-23516",
"System.Threading": "4.0.11-beta-23516"
And I try the following code:
using System;
using System.Data.SqlClient;
namespace DBTest
public class Program
public static void Main(string[] args)
using (SqlConnection con = new SqlConnection(ConnStr)) {
con.Open();
try {
using (SqlCommand command = new SqlCommand("SELECT * FROM SAMPLETABLE", con)) {
command.ExecuteNonQuery();
catch {
Console.WriteLine("Something went wrong");
Console.Read();
But get the following errors:
Anyone else got this working?
–
–
–
–
System.Data.Common and System.Data.SqlClient.
Currently this creates dependency in project.json –> aspnetcore50
section to these two libraries.
"aspnetcore50": {
"dependencies": {
"System.Runtime": "4.0.20-beta-22523",
"System.Data.Common": "4.0.0.0-beta-22605",
"System.Data.SqlClient": "4.0.0.0-beta-22605"
Try getting System.Data.Common and System.Data.SqlClient via Nuget and see if this adds the above dependencies for you, but in a nutshell you are missing System.Runtime.
Edit: As per Mozarts answer, if you are using .NET Core 3+, reference Microsoft.Data.SqlClient
instead.
–
–
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.