diff --git a/ShardingCore.sln b/ShardingCore.sln
index c30bb8f7..0bf2e686 100644
--- a/ShardingCore.sln
+++ b/ShardingCore.sln
@@ -32,6 +32,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShardingCore.MySql.3x", "sr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShardingCore.MySql.2x", "src2x\ShardingCore.MySql.2x\ShardingCore.MySql.2x.csproj", "{0CF88F0B-6CCB-49B5-B41D-CDC193B51581}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShardingCore.Test50.MySql", "test\ShardingCore.Test50.MySql\ShardingCore.Test50.MySql.csproj", "{C8FAB96F-F13E-4094-883C-2D38D39EE4A3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -49,6 +51,7 @@ Global
{10308339-FF5C-43AB-9208-627B6E2FBBDB} = {490FAE47-4476-4508-B216-505FC850447F}
{954C4CA2-9CF4-4C2C-8DE6-180DD8202E38} = {62AAE0FE-4099-4A48-AA3C-F76F14C62655}
{0CF88F0B-6CCB-49B5-B41D-CDC193B51581} = {679E6084-0C45-4807-BFEE-D2FDA44B2188}
+ {C8FAB96F-F13E-4094-883C-2D38D39EE4A3} = {CC2C88C0-65F2-445D-BE78-973B840FE281}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3CAF09A6-6ABD-41D9-BA57-9A822B8095F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -95,5 +98,9 @@ Global
{0CF88F0B-6CCB-49B5-B41D-CDC193B51581}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0CF88F0B-6CCB-49B5-B41D-CDC193B51581}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0CF88F0B-6CCB-49B5-B41D-CDC193B51581}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C8FAB96F-F13E-4094-883C-2D38D39EE4A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C8FAB96F-F13E-4094-883C-2D38D39EE4A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C8FAB96F-F13E-4094-883C-2D38D39EE4A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C8FAB96F-F13E-4094-883C-2D38D39EE4A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/test/ShardingCore.Test50.MySql/Configs/DbConfig.json b/test/ShardingCore.Test50.MySql/Configs/DbConfig.json
new file mode 100644
index 00000000..4e353d58
--- /dev/null
+++ b/test/ShardingCore.Test50.MySql/Configs/DbConfig.json
@@ -0,0 +1,6 @@
+{
+ "MySql": {
+ "ConnectionString": "server=localhost;port=3306;user=root;password=123456;database=ShardingCoreDB;sslMode=None;"
+ }
+
+}
\ No newline at end of file
diff --git a/test/ShardingCore.Test50.MySql/ShardingCore.Test50.MySql.csproj b/test/ShardingCore.Test50.MySql/ShardingCore.Test50.MySql.csproj
new file mode 100644
index 00000000..229291ae
--- /dev/null
+++ b/test/ShardingCore.Test50.MySql/ShardingCore.Test50.MySql.csproj
@@ -0,0 +1,40 @@
+
+
+
+ net5.0
+ TRACE;DEBUG;EFCORE5MYSQL;
+ ShardingCore.Test50
+ ShardingCore.Test50
+ ShardingCore.Test50
+ ShardingCore.Test50
+ 9.0
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ PreserveNewest
+ PreserveNewest
+
+
+
diff --git a/test/ShardingCore.Test50/ShardingCore.Test50.csproj b/test/ShardingCore.Test50/ShardingCore.Test50.csproj
index 1d54417d..de8c2967 100644
--- a/test/ShardingCore.Test50/ShardingCore.Test50.csproj
+++ b/test/ShardingCore.Test50/ShardingCore.Test50.csproj
@@ -3,6 +3,7 @@
net5.0
9.0
+ TRACE;DEBUG;EFCORE5SQLSERVER;
diff --git a/test/ShardingCore.Test50/Startup.cs b/test/ShardingCore.Test50/Startup.cs
index 31f76581..e568fcff 100644
--- a/test/ShardingCore.Test50/Startup.cs
+++ b/test/ShardingCore.Test50/Startup.cs
@@ -2,15 +2,22 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ShardingCore.DbContexts.VirtualDbContexts;
using ShardingCore.Extensions;
-using ShardingCore.SqlServer;
using ShardingCore.Test50.Domain.Entities;
using ShardingCore.Test50.Shardings;
+#if EFCORE5SQLSERVER
+using ShardingCore.SqlServer;
+#endif
+#if EFCORE5MYSQL
+using ShardingCore.MySql;
+#endif
+
namespace ShardingCore.Test50
{
/*
@@ -21,7 +28,7 @@ namespace ShardingCore.Test50
*/
public class Startup
{
- // 自定义 host 构建
+ // // 自定义 host 构建
public void ConfigureHost(IHostBuilder hostBuilder)
{
hostBuilder
@@ -37,6 +44,7 @@ namespace ShardingCore.Test50
// ConfigureServices(HostBuilderContext hostBuilderContext, IServiceCollection services)
public void ConfigureServices(IServiceCollection services, HostBuilderContext hostBuilderContext)
{
+#if EFCORE5SQLSERVER
services.AddShardingSqlServer(o =>
{
o.ConnectionString = hostBuilderContext.Configuration.GetSection("SqlServer")["ConnectionString"];
@@ -47,6 +55,20 @@ namespace ShardingCore.Test50
config.EnsureCreated = true;
});
});
+#endif
+#if EFCORE5MYSQL
+ services.AddShardingMySql(o =>
+ {
+ o.ConnectionString = hostBuilderContext.Configuration.GetSection("MySql")["ConnectionString"];
+ o.ServerVersion = new MySqlServerVersion(new Version());
+ o.AddSharding();
+ o.AddSharding();
+ o.CreateIfNotExists((provider, config) =>
+ {
+ config.EnsureCreated = true;
+ });
+ });
+#endif
}
// 可以添加要用到的方法参数,会自动从注册的服务中获取服务实例,类似于 asp.net core 里 Configure 方法