SapientGuardian / SapientGuardian.EntityFrameworkCore.MySql

MySQL database provider for Entity Framework Core
52 stars 9 forks source link

Support for UWP Framework #37

Open scout208 opened 7 years ago

scout208 commented 7 years ago

I have a UWP project in which I tried installing this package via Nuget Package Manager as described here in Visual Studio 2015 and I get the following errors:

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-arm).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-x64).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-x86).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : System.Net.Security 4.0.0 provides a compile-time reference assembly for System.Net.Security on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot).
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Package restore failed for 'UWP SQLite Example'.
Install-Package : Package restore failed. Rolling back package changes for 'UWP SQLite Example'.
At line:1 char:1
+ Install-Package SapientGuardian.EntityFrameworkCore.MySql
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Here is my project.json:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "SQLite.Net-PCL": "3.1.1",
    "winrtxamltoolkit": "2.0.0"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

Any news on how to get this running on UWP? Thanks!

SapientGuardian commented 7 years ago

Try changing your project.json frameworks section like this:

 "frameworks": {
    "uap10.0": {
      "imports": [
        "netstandard1.3"
      ]
    }
  }
scout208 commented 7 years ago

I just tried that. So I updated my project.json to this:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "SQLite.Net-PCL": "3.1.1",
    "winrtxamltoolkit": "2.0.0"
  },
  "frameworks": {
    "uap10.0": {
      "imports": [
        "netstandard1.3"
      ]
    }
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

did a rebuild and then tried installing via the Nuget Package Manager again and still got the exact same error.

Just to be sure, I also tried updating my project.json to this:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2",
    "SQLite.Net-PCL": "3.1.1",
    "winrtxamltoolkit": "2.0.0",
    "SapientGuardian.EntityFrameworkCore.MySql": "7.1.14"
  },
  "frameworks": {
    "uap10.0": {
      "imports": [
        "netstandard1.3"
      ]
    }
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

and doing a rebuild, but it gave me the same errors.

SapientGuardian commented 7 years ago

Hm, not sure then. I haven't done anything with uap. We are targeting netstandard 1.3, which https://docs.microsoft.com/en-us/dotnet/articles/standard/library says should work with uap10. This is probably a better question for stackoverflow.

scout208 commented 7 years ago

Okay, I've ran into this same problem before with other libraries and it seems part of the answer is here. There's a problem with having the dependencies 'System.Threading.Thread' and 'System.Net.Security' as you can see if you look closely at the error report. For some reason these classes just aren't in UWP. Like they said,

Thread does not appear in UWP simply by having it in .NET Core -- after all we already shipped it in .NET Core. We have to update the framework available to UWP.

Although some work has begun in getting it supported.

So the solution is either to figure out a way to get the library to work without those dependencies or wait until the .NET team comes around to releasing a version of UWP that has these classes supported.

SapientGuardian commented 7 years ago

Neither of those are a direct dependency of this library, but they are of the underlying mysql connector, https://github.com/SapientGuardian/mysql-connector-net-netstandard. I took a quick look at their usage... System.Threading.Thread is used for a sleep, which is terrible and should be removed. System.Net.Security is used for SSL; I don't think we can get rid of that quite so easily.

scout208 commented 7 years ago

So, it seems like the best solution is just to wait and hope that UWP supports System.Net.Security sometime in the near future?

SapientGuardian commented 7 years ago

If you're really desperate and don't need SSL, you could make your own build of the connector library that doesn't have the dependency.

scout208 commented 7 years ago

Okay, I'll give it a shot and see what I can come up with, thanks!