修复动态分库发布x.5.0.8
This commit is contained in:
parent
d12fab7b90
commit
b2bb289669
|
@ -1,9 +1,9 @@
|
|||
:start
|
||||
::定义版本
|
||||
set EFCORE2=2.5.0.8
|
||||
set EFCORE3=3.5.0.8
|
||||
set EFCORE5=5.5.0.8
|
||||
set EFCORE6=6.5.0.8
|
||||
set EFCORE2=2.5.0.9
|
||||
set EFCORE3=3.5.0.9
|
||||
set EFCORE5=5.5.0.9
|
||||
set EFCORE6=6.5.0.9
|
||||
|
||||
::删除所有bin与obj下的文件
|
||||
@echo off
|
||||
|
|
|
@ -15,6 +15,7 @@ using System.Diagnostics;
|
|||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using ShardingCore.Core.DbContextCreator;
|
||||
using ShardingCore.EFCores.OptionsExtensions;
|
||||
using ShardingCore.Helpers;
|
||||
using ShardingCore.Sharding.ReadWriteConfigurations;
|
||||
using ShardingCore.Sharding.ShardingComparision;
|
||||
using ShardingCore.Sharding.ShardingComparision.Abstractions;
|
||||
|
@ -144,6 +145,7 @@ namespace Sample.SqlServer
|
|||
app.UseRouting();
|
||||
|
||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||
DynamicShardingHelper.DynamicAppendDataSource<DefaultShardingDbContext>("c1","B", "Data Source=localhost;Initial Catalog=ShardingCoreDBXAABB;Integrated Security=True;");
|
||||
app.DbSeed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sample.SqlServerShardingDataSource.Entities;
|
||||
using ShardingCore.Helpers;
|
||||
|
||||
namespace Sample.SqlServerShardingDataSource.Controllers
|
||||
{
|
||||
|
@ -21,8 +22,9 @@ namespace Sample.SqlServerShardingDataSource.Controllers
|
|||
/// 动态追加分库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public IActionResult Queryabc()
|
||||
//public IActionResult Queryabc()
|
||||
//{
|
||||
// DynamicShardingHelper.DynamicAppendDataSource();
|
||||
// DbContextHelper.CreateSubDb("X", "Data Source=localhost;Initial Catalog=EFCoreShardingDataSourceDBX;Integrated Security=True;");
|
||||
// return Ok();
|
||||
//}
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources.Abstractions;
|
||||
using ShardingCore.Core.VirtualDatabase.VirtualDataSources.PhysicDataSources;
|
||||
using ShardingCore.DynamicDataSources;
|
||||
using ShardingCore.Exceptions;
|
||||
using ShardingCore.Sharding.Abstractions;
|
||||
|
@ -57,6 +58,7 @@ namespace ShardingCore.Helpers
|
|||
public static void DynamicAppendDataSource<TShardingDbContext>(IVirtualDataSource<TShardingDbContext> virtualDataSource, string dataSourceName, string connectionString) where TShardingDbContext : DbContext, IShardingDbContext
|
||||
{
|
||||
var defaultDataSourceInitializer = ShardingContainer.GetService<IDataSourceInitializer<TShardingDbContext>>();
|
||||
virtualDataSource.AddPhysicDataSource(new DefaultPhysicDataSource(dataSourceName, connectionString, false));
|
||||
defaultDataSourceInitializer.InitConfigure(virtualDataSource, dataSourceName, connectionString, false);
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -72,6 +74,7 @@ namespace ShardingCore.Helpers
|
|||
var virtualDataSourceManager = ShardingContainer.GetService<IVirtualDataSourceManager<TShardingDbContext>>();
|
||||
|
||||
var virtualDataSource = virtualDataSourceManager.GetVirtualDataSource(configId);
|
||||
virtualDataSource.AddPhysicDataSource(new DefaultPhysicDataSource(dataSourceName, connectionString, false));
|
||||
defaultDataSourceInitializer.InitConfigure(virtualDataSource, dataSourceName, connectionString, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue