MySQL Connector/Net Developer Guide


This manual describes how to install and configure MySQL Connector/Net, the connector that enables .NET applications to communicate with MySQL servers, and how to use it to develop database applications.

For notes detailing the changes in each release of Connector/Net, see MySQL Connector/Net Release Notes.

For legal information, see the Legal Notices.

For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss your issues with other MySQL users.

For additional documentation on MySQL products, including translations of the documentation into other languages, and downloadable versions in variety of formats, including HTML and PDF formats, see the MySQL Documentation Library.

Licensing information.  This product may include third-party software, used under license. If you are using a Commercial release of MySQL Connector/Net, see this document for licensing information, including licensing information relating to third-party software that may be included in this Commercial release. If you are using a Community release of MySQL Connector/Net, see this document for licensing information, including licensing information relating to third-party software that may be included in this Community release.

Document generated on: 2018-01-13 (revision: 55452)

Table of Contents

Preface and Legal Notices
1 Introduction to MySQL Connector/Net
2 Connector/Net Versions
3 Connector/Net Installation
3.1 Installing Connector/Net on Windows
3.1.1 Installing Connector/Net Using MySQL Installer
3.1.2 Installing Connector/Net Using the Standalone Installer
3.2 Installing Connector/Net on Unix with Mono
3.3 Installing Connector/Net from the Source Code
4 Connector/Net Tutorials
4.1 Tutorial: An Introduction to Connector/Net Programming
4.1.1 The MySqlConnection Object
4.1.2 The MySqlCommand Object
4.1.3 Working with Decoupled Data
4.1.4 Working with Parameters
4.1.5 Working with Stored Procedures
4.2 Tutorial: MySQL Connector/Net ASP.NET Membership and Role Provider
4.3 Tutorial: MySQL Connector/Net ASP.NET Profile Provider
4.4 Tutorial: Web Parts Personalization Provider
4.5 Tutorial: Simple Membership Web Provider
4.5.1 Requirements
4.5.2 Creating and Configuring a New Project
4.5.3 Adding OAuth Authentication to a Project
4.6 Tutorial: Using an Entity Framework Entity as a Windows Forms Data Source
4.7 Tutorial: Data Binding in ASP.NET Using LINQ on Entities
4.8 Tutorial: Generating MySQL DDL from an Entity Framework Model
4.9 Tutorial: Accessing JSON Documents with MySQL Connector/Net
4.10 Tutorial: Using SSL with MySQL Connector/Net
4.11 Tutorial: Using MySqlScript
4.11.1 Using Delimiters with MySqlScript
5 Connector/Net Programming
5.1 Connecting to MySQL Using Connector/Net
5.1.1 Creating a Connector/Net Connection String
5.1.2 Handling Connection Errors
5.1.3 Using GetSchema on a Connection
5.2 Using MySqlCommand
5.3 Using Connector/Net with Connection Pooling
5.4 Using the Windows Native Authentication Plugin
5.5 Writing a Custom Authentication Plugin
5.6 Using Connector/Net with Table Caching
5.7 Using the Connector/Net with Prepared Statements
5.7.1 Preparing Statements in Connector/Net
5.8 Accessing Stored Procedures with Connector/Net
5.8.1 Using Stored Routines from Connector/Net
5.9 Handling BLOB Data With Connector/Net
5.9.1 Preparing the MySQL Server
5.9.2 Writing a File to the Database
5.9.3 Reading a BLOB from the Database to a File on Disk
5.10 Asynchronous Methods
5.11 Using the Connector/Net Interceptor Classes
5.12 Handling Date and Time Information in Connector/Net
5.12.1 Fractional Seconds
5.12.2 Problems when Using Invalid Dates
5.12.3 Restricting Invalid Dates
5.12.4 Handling Invalid Dates
5.12.5 Handling NULL Dates
5.13 Using the MySqlBulkLoader Class
5.14 Using the MySQL Connector/Net Trace Source Object
5.14.1 Viewing MySQL Trace Information
5.14.2 Building Custom Listeners
5.15 Binary/Nonbinary Issues
5.16 Character Set Considerations for Connector/Net
5.17 Using Connector/Net with Crystal Reports
5.17.1 Creating a Data Source
5.17.2 Creating the Report
5.17.3 Displaying the Report
5.18 ASP.NET Provider Model
5.19 Working with Partial Trust / Medium Trust
5.19.1 Evolution of Partial Trust Support Across Connector/Net Versions
5.19.2 Configuring Partial Trust with Connector/Net Library Installed in GAC
5.19.3 Configuring Partial Trust with Connector/Net Library Not Installed in GAC
6 Connector/Net Connection-String Options Reference
7 Connector/Net for Windows Store
8 Connector/Net for Entity Framework
8.1 Entity Framework 5 Support
8.2 Entity Framework 6 Support
8.3 Entity Framework Core Support
8.3.1 Creating a Database with Code First in EF Core
8.3.2 Scaffolding an Existing Database in EF Core
8.3.3 Configuring Character Sets and Collations in EF Core
9 Connector/Net API Reference
9.1 MySql.Data.MySqlClient Namespace
9.1.1 MySql.Data.MySqlClientHierarchy
9.1.2 BaseCommandInterceptor Class
9.1.3 BaseExceptionInterceptor Class
9.1.4 MySqlCommand Class
9.1.5 MySqlCommandBuilder Class
9.1.6 MySqlConnection Class
9.1.7 MySqlDataAdapter Class
9.1.8 MySqlDataReader Class
9.1.9 MySqlDbType Enumeration
9.1.10 MySqlError Class
9.1.11 MySqlErrorCode Enumeration
9.1.12 MySqlException Class
9.1.13 MySqlHelper Class
9.1.14 MySqlInfoMessageEventArgs Class
9.1.15 MySqlInfoMessageEventHandler Delegate
9.1.16 MySqlParameter Class
9.1.17 MySqlParameterCollection Class
9.1.18 MySqlRowUpdatedEventArgs Class
9.1.19 MySqlRowUpdatedEventHandler Delegate
9.1.20 MySqlRowUpdatingEventArgs Class
9.1.21 MySqlRowUpdatingEventHandler Delegate
9.1.22 MySqlTransaction Class
9.2 MySql.Data.Types Namespace
9.2.1 MySql.Data.TypesHierarchy
9.2.2 MySqlConversionException Class
9.2.3 MySqlDateTime Structure
9.3 MySql.Data.MySqlClient.Memcached Namespace
9.3.1 BinaryClient Class
9.3.2 Client Class
9.3.3 TextClient Class
9.4 MySql.Data.MySqlClient.Replication Namespace
9.4.1 ReplicationManager Class
9.4.2 ReplicationRoundRobinServerGroup Class
9.4.3 ReplicationServer Class
9.4.4 ReplicationServerGroup Class
10 Connector/Net Support
10.1 Connector/Net Community Support
10.2 How to Report Connector/Net Problems or Bugs
11 Connector/Net FAQ