Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET and MySQL .Net Framework Data Provider Issues

Tags:

mysql

asp.net

I'm new in ASP.NET. Everytime I try to run my application, I encounter the error message below. I already installed .Net Framework Data Provider for MySQL several times. I hope someone can help me on this. Thanks in advance.

Server Error in '/PLDT QuickSearcher' Application.

Unable to find the requested .Net Framework Data Provider.  It may not be installed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed.
like image 398
SiHyung Lee Avatar asked Nov 09 '11 08:11

SiHyung Lee


People also ask

Which is the data provider for .NET framework?

The . NET Framework Data Provider for Oracle (OracleClient) enables data access to Oracle data sources through Oracle client connectivity software. The data provider supports Oracle client software version 8.1. 7 or a later version.

What is .NET Framework data provider for SQL Server?

The . NET Framework Data Provider for SQL Server (SqlClient) uses its own protocol to communicate with SQL Server. It is lightweight and performs well because it is optimized to access a SQL Server directly without adding an OLE DB or Open Database Connectivity (ODBC) layer.

What is data provider in asp net?

NET data provider is a software library consisting of classes that provide data access services such as connecting to a data source, executing commands at a data source and fetching data from a data source with support to execute commands within transactions.

What namespace is used for using SQL as .NET Framework data provider?

The . NET Framework Data Provider for SQL Server classes are located in the System. Data. SqlClient namespace.


2 Answers

Add MySql.Data.dll as reference to the project
Add this block to web.config:

<system.data>
    <DbProviderFactories>
        <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data" />
    </DbProviderFactories>
</system.data> 
like image 77
Filip Avatar answered Oct 04 '22 08:10

Filip


Reference the MySql.Data and MySql.Entities Nuget packages. Then add this line to your web 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=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  </DbProviderFactories>
</system.data>

Your connection string should be similar to the following:

<add name="MyDb" connectionString="Server=127.0.0.1;Port=3306;Database=MyDb;Uid=root;Pwd=;" providerName="MySql.Data.MySqlClient" />
like image 22
sky-dev Avatar answered Oct 04 '22 08:10

sky-dev