This post was last edited by QWERTYU on 2020-11-11 09:14
Scenario: Open a .NET project using the mysql database and install it in the local development environment.NET MySQL connector, everything is working fine, but when it is released to iis, the program is abnormal and the error message is as follows:
Exception information: System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver. <GetService>b__0---> exception information: The ADO.NET provider with the fixed name "MySql.Data.MySqlClient" is not registered in the computer or application profile or cannot be loaded. For more information, see Internal Exceptions.
InnerException:System.ArgumentException: 找不到请求的 .Net Framework Data Provider。可能没有安装。
Find the problem: Found that the server is not installed.NET MySQL connector, because mysql uses Alibaba Cloud's cloud database, there are also multiple servers, in order to avoid installation on each server.NET MySQL connector,To do this, I made sure to set the MySQL references to "local copy" so that I could copy them to the bin folder and add the following to my app.config:
After adding the above configuration, it works fine on the server and I can deploy the application without installing the MySQL connector on the server, but now I have a problem on my local dev machine (with the MySQL connector installed) and I get this error when I try EF connection: Exception information: System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver. <GetService>b__0---> exception information: The ADO.NET provider with the fixed name "MySql.Data.MySqlClient" is not registered in the computer or application profile or cannot be loaded. For more information, see Internal Exceptions. InnerException:System.ArgumentException: 找不到请求的 .Net Framework Data Provider。可能没有安装。 Try the action: If I comment out the XML added above in the config, the error goes away. This may be because the same driver is installed on the system and is located in machine.config. The final solution and why:
Try adding <remove invariant="MySql.Data.MySqlClient" /> in your webconfig. On your machine, you already have the MySql connector installed, and you modify your machine.config by adding one in DbProviderFactories. So if you put another MySql data provider in your web.config, it's as if you tried to register the same thing twice.
|