diff --git a/src/ShardingCore/DynamicDataSources/DefaultDataSourceInitializer.cs b/src/ShardingCore/DynamicDataSources/DefaultDataSourceInitializer.cs index 8dccb787..26bd9ab6 100644 --- a/src/ShardingCore/DynamicDataSources/DefaultDataSourceInitializer.cs +++ b/src/ShardingCore/DynamicDataSources/DefaultDataSourceInitializer.cs @@ -170,7 +170,7 @@ namespace ShardingCore.DynamicDataSources if (context is IShardingDbContext shardingDbContext) { using (var dbContext = - shardingDbContext.GetDbContext(dataSourceName, false, + shardingDbContext.GetDbContext(dataSourceName, true, _routeTailFactory.Create(string.Empty, false))) { var isDefault = virtualDataSource.IsDefault(dataSourceName); @@ -193,7 +193,7 @@ namespace ShardingCore.DynamicDataSources { if (context is IShardingDbContext shardingDbContext) { - using (var dbContext = shardingDbContext.GetDbContext(dataSourceName, false, + using (var dbContext = shardingDbContext.GetDbContext(dataSourceName, true, _routeTailFactory.Create(string.Empty, false))) { dbContext.RemoveDbContextAllRelationModel(); diff --git a/src/ShardingCore/TableCreator/ShardingTableCreator.cs b/src/ShardingCore/TableCreator/ShardingTableCreator.cs index 6449cabf..a2c8b131 100644 --- a/src/ShardingCore/TableCreator/ShardingTableCreator.cs +++ b/src/ShardingCore/TableCreator/ShardingTableCreator.cs @@ -54,7 +54,7 @@ namespace ShardingCore.TableCreator { var shardingDbContext = (IShardingDbContext)dbContext; - using (var context = shardingDbContext.GetDbContext(dataSourceName, false, + using (var context = shardingDbContext.GetDbContext(dataSourceName, true, _routeTailFactory.Create(tail, false))) { context.RemoveDbContextRelationModelSaveOnlyThatIsNamedType(shardingEntityType);