.NET与MySql.Data的兼容性

时间:2017-10-05 16:00:24

标签: c# mysql .net visual-studio-code .net-core

我在VS Code(cmd:dotnet new webapi)中设置了一个asp.net webapi项目。我已经安装了Nuget并加载了MySql.Data,Version =" 6.9.9"在我的项目中。恢复项目后(cmd:dotnet restore)我收到以下错误:

error NU1202: Package MySql.Data 6.9.9 is not compatible with netcoreapp1.1 (.NETCoreApp, Version=v1.1)

这是我的.csproj文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2"/>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3"/>
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1"/>
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2"/>
    <PackageReference Include="MySql.Data" Version="6.9.9"/>
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1"/>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0"/>
  </ItemGroup>
</Project>

有谁知道哪些版本兼容? 提前谢谢......

2 个答案:

答案 0 :(得分:1)

通过以下介绍: How to change target framework with VS 2017 RC?我解决了这个问题。

我的csproj-File现在看起来像这样:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
    <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2"/>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3"/>
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1"/>
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2"/>
    <PackageReference Include="MySql.Data" Version="6.9.9"/>
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1"/>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0"/>
  </ItemGroup>
</Project>

恢复项目(cmd:dotnet restore)效果很好!

答案 1 :(得分:0)

我记得,所有的预发布都与.net核心有关。不幸的是,当我尝试了高达6.9.9的所有版本时,它无法正常工作。我一直在使用预发布版本,但没有发现任何问题。当我使用核心1.1时,我使用了预发布版本7.x.此版本最近被删除。但我很确定8.0.8-dmr会起作用。