Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从netcore成功连接到MySQL。Ubuntu 16.04上的ASP C#_C#_Mysql_Nuget_.net Core_Ubuntu 16.04 - Fatal编程技术网

如何从netcore成功连接到MySQL。Ubuntu 16.04上的ASP C#

如何从netcore成功连接到MySQL。Ubuntu 16.04上的ASP C#,c#,mysql,nuget,.net-core,ubuntu-16.04,C#,Mysql,Nuget,.net Core,Ubuntu 16.04,我按照此链接中的说明进行操作 如下图所示。(Program.cs文件) 另外还有ConsoleApp.csproj文件 <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>netcoreapp1.1</TargetFramework> </Prop

我按照此链接中的说明进行操作

如下图所示。(Program.cs文件)

另外还有ConsoleApp.csproj文件

    <Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Google.Protobuf" Version="3.3.0" />
    <PackageReference Include="MySql.Data" Version="8.0.8-dmr" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.8-dmr" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.8-dmr" />
  </ItemGroup>
</Project>
首先使用一个简单的控制台应用程序而不是web来简化错误

但毕竟,我一直在犯以下错误

=====================================================================

dotnet build
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]

Build FAILED.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:02.00
=====================================================================

dotnet build
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]

Build FAILED.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:02.00
是否有我遗漏的东西或我没有安装的东西或什么! 求你了,我真的需要你的帮助来找出问题所在。
谢谢

您在此处标记了asp.net-core-mvc,但您使用的是.net core控制台应用程序。哦,感谢您注意到,我在此处使用.netcore控制台应用程序来了解如何连接,然后再在.netcore web应用程序中使用它#立即编辑它。:)@Janesabouchleich请问您是只使用windows操作系统开发C#web应用程序,还是也使用基于Linux的操作系统,如Ubuntu?我在windows上。也有麻烦让它运行。mscorlib是必需的-这表明它不是在.NET核心/标准上运行,而是在完整的.NET框架上运行。您确定MySql.XDevAPI与.NET Core兼容吗?
dotnet build
Microsoft (R) Build Engine version 15.1.1012.6693
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]

Build FAILED.

Program.cs(1,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(2,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
Program.cs(3,13): error CS0234: The type or namespace name 'XDevAPI' does not exist in the namespace 'MySql' (are you missing an assembly reference?) [/home/filePath/consoleApp/consoleApp.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:02.00