I have a simple ASP.NET vNext class library project which fails to compile when types in System.Data are referenced; what have I done wrong here, or is there a problem in vnext?
I set up my project.json like this:
{
"dependencies": {
"System.Data.Common": "1.0.0-alpha3"
},
"frameworks": {
"net451": {
"dependencies": {
}
},
"k10": {
"dependencies": {
}
}
}
}
While typing the "System.Data.Common" reference, nuget intellisense worked fine; after saving the file, package restore happened as expected.
Then I added an interface to the project which references System.Data.IDbConnection
, like this:
using System.Data;
namespace MyProj.Common.Data
{
public interface IDbConnectionFactory
{
IDbConnection CreateConnection();
}
}
This bombs at build time:
Error 1 The type or namespace name 'IDbConnection' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Administrator\Proj\MyProj\MyProj.Common\Data\IDbConnectionFactory.cs 7 9 MyProj.Common
My KVM list:
C:\Users\Administrator\Proj\MyProj [next +3 ~2 -0 !]> kvm list Active Version Runtime Architecture Location Alias ------ ------- ------- ------------ -------- ----- * 1.0.0-alpha3 svr50 x64 C:\Users\Administrator\.kre\packages default 1.0.0-alpha3 svr50 x86 C:\Users\Administrator\.kre\packages 1.0.0-alpha3 svrc50 x64 C:\Users\Administrator\.kre\packages 1.0.0-alpha3 svrc50 x86 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10364 CLR amd64 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10364 CLR x86 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10364 CoreCLR amd64 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10364 CoreCLR x86 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10365 CLR amd64 C:\Users\Administrator\.kre\packages 1.0.0-alpha4-10365 CLR x86 C:\Users\Administrator\.kre\packages C:\Users\Administrator\Proj\MyProj [next +3 ~2 -0 !]>
The Can ASP.NET vNext use non-vNext references? question seems very similar, but the error message here is somewhat different, and the nuget intellisense suggests that the ADO.NET packages are built for K10.
IDbConnection is defined in System.Data.dll in the desktop version of .NET. It is not included in System.Data.Common, which contains only a subset of the ADO.NET types that will be available across different versions of the runtime. If you are ok with your application being able to work only against desktop .NET you should be able to reference the full System.Data.dll and use any types from it. If you want to be able to target the CoreCLR based runtime you should stick to types defined in System.Data.Common, e.g. in this case you can use DbConnection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With