简体   繁体   English

尽管拥有正确的NuGet软件包,为什么我仍需要在计算机上安装MySQL连接器?

[英]Why do I still need the MySQL Connector installed on the computer despite having the proper NuGet packages?

I've got a C# ASP.NET MVC project using MariaDB with Entity Framework 6. 我有一个使用MariaDB和Entity Framework 6的C#ASP.NET MVC项目。

This project is made in Visual Studio 2017 and it took me some long hours double-checking whether I had the proper MySQL connector's assembly references added as they should, in the form of NuGet packages MySql.Data 8.0.13 and MySql.Data.EntityFramework 8.0.13 (both oficially published by Oracle), because I was getting the following error when browsing Views while debugging: 这个项目是在Visual Studio 2017中完成的,我花了很长时间仔细检查我是否以NuGet包MySql.Data 8.0.13MySql.Data.EntityFramework的形式适当添加了正确的MySQL连接器的程序集引用。 8.0.13 (均为oficially由Oracle出版),因为我在浏览美景,一边调试时收到以下错误:

The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file. 具有不变名称'MySql.Data.MySqlClient'的ADO.NET提供程序未在计算机或应用程序配置文件中注册。

Until I gave up on it and tried installing the MySQL Connector/NET 8.0 , after which it worked. 直到我放弃了它,并试图安装的MySQL连接器/ NET 8.0 ,在这之后的工作。 No changes made to the web.config file other than those performed by NuGet. 除了由NuGet执行的更改外,没有对web.config文件进行任何更改。

I checked the assemblies placed under %ProgramFiles%\\MySql\\Connector by the installer, and they are bit-identical to those pulled by NuGet. 我检查了安装程序放置在%ProgramFiles%\\MySql\\Connector下的程序集,它们与NuGet提取的程序集完全相同。 Heck, I even deleted the entire folder, and it still worked . 哎呀, 我什至删除了整个文件夹,它仍然有效

What gives? 是什么赋予了? Are the NuGet packages missing some step they should perform? NuGet软件包是否缺少应执行的某些步骤?

I suspect that the Connector/NET 8.0 installer modifies your C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config file, which is shared by all .NET applications on the machine. 我怀疑Connector / NET 8.0安装程序会修改您的C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\config\\machine.config文件,该文件由计算机上的所有.NET应用程序共享。 Unfortunately, this is a local change on your machine, which means that your application may not work properly when deployed. 不幸的是,这是计算机上的本地更改,这意味着您的应用程序在部署后可能无法正常运行。

The solution is to add MySql.Data to your app.config (or Web.config ) file. 解决方案是将MySql.Data添加到您的app.config (或Web.config )文件中。 I'm not sure if the NuGet packages are designed to do this automatically or not. 我不确定NuGet软件包是否旨在自动执行此操作。

Per the Oracle docs , add this information to app.config : 根据Oracle文档 ,将此信息添加到app.config

<system.data>
   <DbProviderFactories>
     <remove invariant="MySql.Data.MySqlClient" />
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" 
          type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   </DbProviderFactories>
</system.data>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果已经安装了SDK,为什么需要使用nuget将ASP.NET Core软件包添加到项目中? - Why do I need to use nuget to add ASP.NET Core packages into my project if I already have the SDK installed? 如何列出所有已安装的 NuGet 包? - How do I list all installed NuGet packages? 为什么尽管有“使用”声明,但仍需要包括我的部分名称空间? - Why do I need to include part of my namespace despite having a 'using' declaration? 我如何在未安装mysql连接器的情况下运行mysql应用程序? - How do i run a mysql app without mysql connector installed? 如何运行安装了 mysql 连接器的 mysql 应用程序? - How do i run a mysql app with mysql connector installed? 尽管已安装软件包,但无法找到 NuGet 软件包 NU1101 - Unable to find NuGet packages despite packages being installed NU1101 Visual Studio编译错误-计算机中缺少nuget软件包,但是nuget restore表示已安装所有软件包? - Visual Studio compile error - nuget package missing from computer, but nuget restore says all packages installed? 该项目引用了此计算机上没有的NuGet软件包 - The project references NuGet packages that are not on this computer 我是否需要使用Syncfusion Essential Studio或者我可以使用NuGet包吗? - Do I need to use Syncfusion Essential Studio or can I just use NuGet packages? NuGet软件包声称未正确安装 - NuGet Packages claiming to not be correctly installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM