Giter Club home page Giter Club logo

pomelo.entityframeworkcore.mysql's Introduction

Pomelo.EntityFrameworkCore.MySql

Travis build status AppVeyor build status NuGet MyGet Join the chat at https://gitter.im/PomeloFoundation/Home

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

Nightly Builds

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://www.myget.org/F/pomelo/api/v3/index.json" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

Getting Started

1. Recommended Server CharSet

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';

2. CSPROJ Configuration

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>

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;

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
                    }
            ));
        }
    }
}

NO_BACKSLASH_ESCAPES

The escaping style can be configured to support SQL mode NO_BACKSLASH_ESCAPES by adding .DisableBackslashEscaping() to your MySQL option configuration.

mysqlOptions =>
{
    mysqlOptions
    .ServerVersion(new Version(5, 7, 17), ServerType.MySql); // replace with your Server Version and Type
    //further MySQL option configurations go here
    .DisableBackslashEscaping();
}

PLEASE NOTE This option does not set the SQL mode and will not check if it matches the actual database configuration either. Do not use this option unless you are absolutely sure it will always be set when queries are performed on the context. As of today, it also does not apply to parameter values in insert or update statements; do not use it when the context is used to update entries.

View our MySql Provider Configuration Options Wiki Page for a complete list of supported 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.

Schedule and Roadmap

Milestone Release week
2.1.4 11/29/2018
2.2.0 2/7/2019

Scaffolding Tutorial

Using the tool to execute scaffolding commands:

dotnet ef dbcontext scaffold "Server=localhost;Database=ef;User=root;Password=123456;" "Pomelo.EntityFrameworkCore.MySql"

Contribute

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.

License

MIT

pomelo.entityframeworkcore.mysql's People

Contributors

akamyshanov avatar andriysvyryd avatar applenele avatar bgrainger avatar caleblloyd avatar csboling avatar erolkskn avatar jaredatadevsco avatar jeanressouche avatar joepb avatar lordmike avatar luckywraptor avatar maumar avatar meberem avatar mguinness avatar miyamuramiyako avatar moldovans avatar nagstaku avatar neogeneva avatar nover avatar pedro-pedrosa avatar pkiers avatar rafaelblink avatar ralmsdeveloper avatar reed-jones avatar robbieknuth avatar stefannikolei avatar wiredbarb avatar xcellsoft avatar yukozh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.