Reputation: 17657
I created a new Asp.Net core 2.0 project, added MySql.Data
When I try:
mySqlConnection.Open();
then this exception occurs:
An unhandled exception occurred while processing the request. FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. O sistema não pode encontrar o arquivo especificado. MySql.Data.MySqlClient.MySqlConnectAttrs.get_OSDetails() TargetInvocationException: Exception has been thrown by the target of an invocation. System.RuntimeMethodHandle.InvokeMethod(object target, Object[] arguments, Signature sig, bool constructor)
I searched and did not find System.Management on NuGet for ASP.Net Core.
Also on the Dependencies (References), This shows on:
Package 'MySql.Data.6.9.9' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
How to connect to MySQL using Nuget on this situation?
Upvotes: 0
Views: 1146
Reputation: 7019
For the .net core only the pre-release nugets work. As of now the latest version is 8.0.8-dmr. To access these you can either check the "include prereleases" option in your nuget manager or for packet manager you can use:
Install-Package MySql.Data -Version 8.0.8-dmr
Or on CLI you can use:
dotnet add package MySql.Data --version 8.0.8-dmr
Upvotes: 1