Documentation Home
MySQL Connector/NET Developer Guide
Related Documentation Download this Manual

8.2 Entity Framework Core Support

MySQL Connector/NET integrates support for Entity Framework (EF) Core, but also offers support for Entity Framework 6 (EF6). This section explains the new features in EF Core implemented in Connector/NET.

In this section:

Requirements for EF Core Support

Configuration with MySQL

To use Entity Framework Core with a MySQL database, do the following:

  1. Install the MySql.Data.EntityFrameworkCore NuGet package.

    For EF Core 1.x only: If you plan to scaffold a database, install the MySql.Data.EntityFrameworkCore.Design NuGet package as well.

    All packages will install the additional packages required to run your application. For instructions on adding a NuGet package, see the relevant Microsoft documentation.

  2. In the class that derives from the DbContext class, override the OnConfiguring method to set the MySQL data provider with UseMySQL. The following example shows how to set the provider using a generic connection string in C#.

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
         #warning To protect potentially sensitive information in your connection string, 
         you should move it out of source code. See 
         for guidance on storing connection strings.

EF Core Features

Following are the features in EF Core implemented by Connector/NET :

  • Database Schema Management

    • Database creation and deletion APIs

    • Relational database migrations

    • Reverse-engineer from database

  • Query

    • Basic LINQ support

    • Mixed client/server evaluation

    • NoTracking

    • Eager loading

    • Raw SQL queries

  • SaveChanges

    • Basic save functionality

    • Optimistic concurrency

    • Transactions

  • Modeling

    • Basic modeling

    • Built-in conventions

    • Fluent API

    • Data annotations

    • Relationships

    • Shadow state properties

    • Relational: table mapping

  • EF Core 1.1

    • DbSet.Find

    • Simplified service replacement

  • Scaffolding

    • Filter by tables

    • Multiple schemas within a single context


The Connector/NET implementation of EF Core has the following limitations:

  • Memory-Optimized Tables is not supported.

Maximum String Length

The following table shows the maximum length of string types supported by the Connector/NET implementation of EF Core. Length values are in bytes for nonbinary and binary string types, depending on the character set used.

Table 8.2 Maximum Length of strings used with EF Core

Data TypeMaximum Length.NET Type
VARCHAR, VARBINARY65,535string, byte[]
BLOB, TEXT65,535byte[]
LONGBLOB, LONGTEXT4,294,967,295byte[]

For additional information about the storage requirements of the string types, see String Type Storage Requirements.

User Comments
Sign Up Login You must be logged in to post a comment.