I use netcore 1.0.1 and want to open a MySqlConnection. if I use connection.Open() I get the error:
The type "DbConnection" is defined in a net referenced Assembly. Add a reference to the assembly"System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
(Translated from german to english)
In my project.json I import:`
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"net46",
"portable-net45+win8"
]
}`
what is the reason this does not work? I can not find anything in the Nuget-package manager.
imports
doesn't do what I suspect you think it does - it doesn't actually import anything, but it says "When you're trying to resolve a package, if it doesn't support my actual target framework, pretend that I'm targeting these frameworks". You should use it as rarely as possible - ideally not at all. Any time you use it, you're risking this sort of problem.
In terms of DbConnection
, you need to depend on the System.Data.Common
package. It's possible there will be other packages you need too, but that's the one that contains System.Data.DbConnection
.
However, the MySql.Data
package supports netstandard1.6
if you use version 6.10.1-beta or 7.0.7-m61 - and in that case it should pull in System.Data.Common
anyway.
I suggest you:
imports
part of your project.json
MySql.Data
that supports .NET Core. (6.9.9 doesn't.)project.json
to csproj
as wellSee more on this question at Stackoverflow