-1

I have already tried to add SQLClient reference

using System.Data.SqlClient 

But still I got these errors

I have been using macOS

It

temre
  • 189
  • 1
  • 3
  • 15
  • https://stackoverflow.com/questions/35444487/how-to-use-sqlclient-in-asp-net-core – ADyson Dec 19 '17 at 12:32
  • Possible duplicate of [How to use SqlClient in ASP.NET Core?](https://stackoverflow.com/questions/35444487/how-to-use-sqlclient-in-asp-net-core) – vasek Dec 19 '17 at 12:34

2 Answers2

3

Open the solutionExplorer, go to references, right click on it and choose add reference. Now browse for the assembly SqlClient and hit the ok button.


But using the using statement in your code just saves you some additional words in order to shorten and simplify your code. Imagine if you would have added a reference of the assembly System.Data.SqlClient to your project, but didn't write using System.Data.SqlClient;, then you could still create a new SqlConnection object, but you have to add like an address, which assembly shell be used.

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();

But importing the reference needs to be done manual, a few basic assembly references have already been added by default, that's why

using System.Web.Mcv;

knows which referenced assembly is meant. For clarification, have a look at the referenced assemblies in your project and you will find System.Web.Mcv there, so it has been added there already.

L. Guthardt
  • 1,990
  • 6
  • 22
  • 44
0

You need to add the MySQL.Data dll via nuget manager

enter image description here

After that use it as usual,

enter image description here

Marco de Boer
  • 149
  • 1
  • 7