1 Star 0 Fork 0

jex / Pomelo.EntityFrameworkCore.MySql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Pomelo.EntityFrameworkCore.MySql

Build Status NuGet Pomelo.EntityFrameworkCore.MySql package in pomelo-efcore-public feed in Azure Artifacts Join the chat at https://gitter.im/PomeloFoundation/Home

Pomelo.EntityFrameworkCore.MySql is the most popular Entity Framework Core provider for MySQL compatible databases. It supports EF Core 5.0 (and lower) and uses MySqlConnector for high-performance database server communication.

Compatibility

Dependencies

The following versions of MySqlConnector, EF Core and .NET Standard are compatible with Pomelo.EntityFrameworkCore.MySql:

Release Branch MySqlConnector EF Core .NET Standard .NET (Core) .NET Framework
5.0.0-beta.1 master >= 1.3.4 5.0.x 2.1 3.0+ N/A
3.2.5 3.2-maint >= 0.69.10 < 1.0.0 3.1.x 2.0 2.0+ 4.6.1+
3.0.1 3.0-maint >= 0.61.0 < 1.0.0 3.0.x 2.1 3.0+ N/A
2.2.6 2.2-maint >= 0.59.2 < 1.0.0 2.2.6 2.0 2.0+ 4.6.1+

Packages

Supported Databases and Versions

Pomelo.EntityFrameworkCore.MySql is tested at least against the latest 2 minor versions of MySQL and MariaDB. Older versions and other server implementations (e.g. Amazon Aurora) may be compatible (and likely are to a high degree) but are not officially supported or tested.

Currently supported versions are:

  • MySQL 8.0
  • MySQL 5.7
  • MariaDB 10.5
  • MariaDB 10.4
  • MariaDB 10.3

Schedule and Roadmap

Milestone Status Release Date
5.0.0 Announced 2021-04-28 (see #1088)
5.0.0-beta.2 Announced 2021-04-25
5.0.0-beta.1 Released 2021-04-22
5.0.0-alpha.2 Released 2020-11-12
3.2.5 Released 2021-04-21
3.0.1 Released 2019-12-04
2.2.6 Released 2019-10-15
2.1.4 Released 2018-11-29

Nightly Builds

To use nightly builds from our Azure DevOps feed, add a NuGet.config file to your solution root with the following content and enable prereleases:

<?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>

Getting Started

1. Recommended Character Set

We recommend to set utf8mb4 as your MySQL database default character set. This is already the server default in MySQL 8. The following statement will check the charset of the current database:

show variables like 'character_set_database';

2. Project Configuration

Ensure that your .csproj file contains the following reference:

<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-beta.1" />

3. Services Configuration

Add Pomelo.EntityFrameworkCore.MySql to the services configuration in your the Startup.cs file.

using System;
using Microsoft.EntityFrameworkCore;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;

// Replace "YourNamespace" with the namespace of your application.
namespace YourNamespace
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            // Replace with your connection string.
            var connectionString = "server=localhost;user=root;password=1234;database=ef";

            // Replace with your server version and type.
            // Use 'MariaDbServerVersion' for MariaDB.
            // Alternatively, use 'ServerVersion.AutoDetect(connectionString)'.
            // For common usages, see pull request #1233.
            var serverVersion = new MySqlServerVersion(new Version(8, 0, 21));

            // Replace 'YourDbContext' with the name of your own DbContext derived class.
            services.AddDbContextPool<YourDbContext>(
                dbContextOptions => dbContextOptions
                    .UseMySql(connectionString, serverVersion)
                    .EnableSensitiveDataLogging() // These two calls are optional but help
                    .EnableDetailedErrors();      // with debugging (remove for production).
            ));
        }
    }
}

View our Configuration Options Wiki Page for a list of common options.

4. Sample Application

Check out our Integration Tests for an example repository that includes a MVC Application.

5. Read the EF Core Documentation

Refer to Microsoft's EF Core Documentation for detailed instructions and examples on using EF Core.

Scaffolding / Reverse Engineering

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"

Contribute

One of the easiest ways to contribute is to report issues and participate in discussions. You can also contribute by submitting pull requests with code changes and supporting tests.

We are always looking for additional core contributors. If you got a couple of hours a week and know your way around EF Core and MySQL, give us a nudge.

License

MIT

The MIT License (MIT) Copyright (c) 2017 Pomelo Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
C# 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dja/Pomelo.EntityFrameworkCore.MySql.git
git@gitee.com:dja/Pomelo.EntityFrameworkCore.MySql.git
dja
Pomelo.EntityFrameworkCore.MySql
Pomelo.EntityFrameworkCore.MySql
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891