dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.63k stars 1.96k forks source link

List MyCat provider for entity framework core #252

Closed yukozh closed 7 years ago

yukozh commented 8 years ago

/cc @rowanmiller @divega

What is MyCat?

image

MyCAT is an Open-Source software, a large database cluster oriented to enterprises. MyCAT is an enforced database which is a replacement for MySQL and supports transaction and ACID. Regarded as MySQL cluster of enterprise database, MyCAT can take the place of expensive Oracle cluster. MyCAT is also a new type of database, which seems like a SQL Server integrated with the memory cache technology, NoSQL technology and HDFS big data. And as a new modern enterprise database product, MyCAT is combined with the traditional database and new distributed data warehouse. In a word, MyCAT is a fresh new middleware of database.

The target of MyCAT is to smoothly migrate the current stand-alone database and applications to cloud side with low cost and to solve the bottleneck problem caused by the rapid growth of data storage and business scale.

Why use MyCat?

① Install Java8, MySQL 5.7, .NET Core SDK on your server

# add-apt-repository ppa:webupd8team/java
# apt-get update
# apt-get install oracle-java8-installer

# wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
# dpkg -i mysql-apt-config_0.6.0-1_all.deb
# apt-get update
# apt-get install mysql-community-server

# sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
# apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
# apt-get update
# apt-get install dotnet-dev-1.0.0-preview2-003121

② Download Pomelo.EntityFrameworkCore.MyCat.Proxy and MyCat Server

③ Configure the config.json which in Pomelo.EntityFrameworkCore.MyCat.Proxy root path, set the MyCatRootPath.

④ Start the proxy by execute nohup dotnet Pomelo.EntityFrameworkCore.MyCat.Proxy.dll

⑤ Create .NET project. Add Pomelo.EntityFrameworkCore.MyCat into your project.

⑥ Configure your DbContext, declare the distributed mysql node address.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    base.OnConfiguring(optionsBuilder);
    optionsBuilder.UseMyCat("server=192.168.0.129;database=blog;uid=test;pwd=test")
        .UseDataNode("192.168.0.129", "blog_1", "root", "123456")
        .UseDataNode("192.168.0.129", "blog_2", "root", "123456")
        .UseDataNode("192.168.0.129", "blog_3", "root", "123456")
        .UseDataNode("192.168.0.129", "blog_4", "root", "123456");
}

⑦ Create models and using the dotnet ef migrations add Init and dotnet ef database update to init your database.

⑧ Most of functions which provided in Entity Framework Core were supported. You are able to use .Where(), .Count(), .Sum() ... with Pomelo.EntityFrameworkCore.MyCat.

View the sample on YouTube

rowanmiller commented 8 years ago

@Kagamine can you put the "How to use MyCat with .NET Framework or .NET Core" info included in this issue somewhere on your project site so that we can link to it (perhaps in the README for your repo?).

rowanmiller commented 8 years ago

PR submitted for this provider https://github.com/aspnet/EntityFramework.Docs/pull/261