Pomelo.EntityFrameworkCore.MySql
is an Entity Framework Core provider built on top of MySqlConnector that enables the use of the Entity Framework Core ORM with MySQL.
Pomelo.EntityFrameworkCore.MySql is currently looking for core contributors
The following versions of EF Core and .NET Core are compatible with Pomelo.EntityFrameworkCore.MySql
:
Pomelo.EntityFrameworkCore.MySql | EF Core | .NET Core |
---|---|---|
3.0.0-rc1.final (prerelease) | 3.0.0 | 3.0 |
2.2.6 | 2.2.6 | 2.2 / 3.0 |
Pomelo.EntityFrameworkCore.MySql
is tested against the latest 2 minor versions of MySQL
and MariaDB
. Older versions may be compatible but are not officially supported or tested. Currently supported versions are:
- MySQL 8.0
- MySQL 5.7
- MariaDB 10.4
- MariaDB 10.3
Milestone | Status | Release Date |
---|---|---|
3.0.0 | Feature lock | Soon |
3.0.0-rc2 | Announced | 2019-11-04 |
3.0.0-rc1 | Released | 2019-10-06 |
2.2.6 | Released | 2019-10-15 |
2.2.0 | Released | 2019-02-07 |
2.1.4 | Released | 2018-11-29 |
To use nightly builds from our MyGet feed, add a NuGet.config
file in your solution root with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Pomelo" value="https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-public/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
We recommend you to set utf8mb4
as your MySQL database default charset. The following statement will check your DB charset:
show variables like 'character_set_database';
Ensure that your .csproj
file has the following references.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
</ItemGroup>
</Project>
Add Pomelo.EntityFrameworkCore.MySql
to the services configuration in your the Startup.cs
file.
using System;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
namespace YourNamespace // replace "YourNamespace" with the namespace of your application
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// other service configurations go here
services.AddDbContextPool<YourDbContext>( // replace "YourDbContext" with the class name of your DbContext
options => options.UseMySql("Server=localhost;Database=ef;User=root;Password=123456;", // replace with your Connection String
mySqlOptions =>
{
mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MySql); // replace with your Server Version and Type
}
));
}
}
}
View our Configuration Options Wiki Page for a complete list of supported options.
Check out our Integration Tests for an example repository that includes a MVC Application.
Refer to Microsoft's EF Core Documentation for detailed instructions and examples on using EF Core.
Use the EF Core tool to execute scaffolding commands:
dotnet ef dbcontext scaffold "Server=localhost;Database=ef;User=root;Password=123456;TreatTinyAsBoolean=true;" "Pomelo.EntityFrameworkCore.MySql"
One of the easiest ways to contribute is to report issues and participate in discussions on issues. You can also contribute by submitting pull requests with code changes and supporting tests.