Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference System.Data in Visual Studio 2015 targeting .NET Core?

I am trying to access the IDbConnection interface in a class library in order to make a connection object that connects and fetches data from the database, but I just cannot access the IDbConnection interface which was supposed to by in System.Data.dll.

I can't find it anywhere in NuGet either. So, how do I go about it?

Has Microsoft changed the way we make connections to a database as well, or is there any new interface introduced in .NET Core?

like image 434
Nabin Karki Thapa Avatar asked Oct 03 '15 23:10

Nabin Karki Thapa


1 Answers

The IDbConnection, IDbCommand etc. interfaces has been removed from the System.Data.Common namespace in .NET Core. They've been replaced by the DbConnection, DbCommand etc. abstract classes. You can read a discussion on the matter here.

You can take a look at the .NET Core progress for System.Data.Common here. In the future, if you're uncertain whether types have been moved or removed, this might be a good place to check.

The NuGet package you want to install is System.Data.Common, which contains the mentioned types.

like image 118
khellang Avatar answered Oct 24 '22 11:10

khellang