diff --git a/nuget-publish.bat b/nuget-publish.bat index fe6c6e7b..18ec112d 100644 --- a/nuget-publish.bat +++ b/nuget-publish.bat @@ -1,10 +1,10 @@ :start ::定义版本 -set EFCORE7=7.7.0.9 -set EFCORE6=7.6.0.9 -set EFCORE5=7.5.0.9 -set EFCORE3=7.3.0.9 -set EFCORE2=7.2.0.9 +set EFCORE7=7.7.0.12 +set EFCORE6=7.6.0.12 +set EFCORE5=7.5.0.12 +set EFCORE3=7.3.0.12 +set EFCORE2=7.2.0.12 ::删除所有bin与obj下的文件 @echo off diff --git a/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs b/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs index fb7d2c0b..a4b65a72 100644 --- a/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs +++ b/src/ShardingCore/Extensions/DbContextExtensions/DbContextExtensionShardingCore.cs @@ -146,7 +146,7 @@ namespace ShardingCore.Extensions var shardingRuntimeContext = dbContext.GetShardingRuntimeContext(); var entityMetadataManager = shardingRuntimeContext.GetEntityMetadataManager(); -#if EFCORE6 +#if EFCORE6 || EFCORE7 var entityTypes = contextModel.GetEntityTypes(); foreach (var entityType in entityTypes) { @@ -156,8 +156,17 @@ namespace ShardingCore.Extensions } } var contextModelRelationalModel = contextModel.GetRelationalModel() as RelationalModel; + foreach (var keyValuePair in contextModelRelationalModel.Tables) + { + foreach (var valueEntityTypeMapping in keyValuePair.Value.EntityTypeMappings) + { + var x = !entityMetadataManager.IsOnlyShardingDataSource(valueEntityTypeMapping.EntityType.ClrType); + Console.WriteLine(valueEntityTypeMapping.EntityType.ClrType); + Console.WriteLine(x); + } + } var valueTuples = - contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => !entityMetadataManager.IsShardingDataSource(m.EntityType.ClrType) ||entityMetadataManager.TryGet(m.EntityType.ClrType)==null)).Select(o => o.Key).ToList(); + contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => !entityMetadataManager.IsOnlyShardingDataSource(m.EntityType.ClrType))).Select(o => o.Key).ToList(); for (int i = 0; i < valueTuples.Count; i++) { contextModelRelationalModel.Tables.Remove(valueTuples[i]); @@ -174,7 +183,7 @@ namespace ShardingCore.Extensions } var contextModelRelationalModel = contextModel.RelationalModel as RelationalModel; var valueTuples = - contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => !entityMetadataManager.IsShardingDataSource(m.EntityType.ClrType)||entityMetadataManager.TryGet(m.EntityType.ClrType)==null)).Select(o => o.Key).ToList(); + contextModelRelationalModel.Tables.Where(o => o.Value.EntityTypeMappings.Any(m => !entityMetadataManager.IsOnlyShardingDataSource(m.EntityType.ClrType))).Select(o => o.Key).ToList(); for (int i = 0; i < valueTuples.Count; i++) { contextModelRelationalModel.Tables.Remove(valueTuples[i]); @@ -191,7 +200,7 @@ namespace ShardingCore.Extensions _data.Clear(); } } - var list = entityTypes.Where(o => !entityMetadataManager.IsShardingDataSource(o.Value.ClrType) || entityMetadataManager.TryGet(o.Value.ClrType) == null).Select(o => o.Key).ToList(); + var list = entityTypes.Where(o => !entityMetadataManager.IsOnlyShardingDataSource(o.Value.ClrType)).Select(o => o.Key).ToList(); for (int i = 0; i < list.Count; i++) { entityTypes.Remove(list[i]); @@ -216,7 +225,7 @@ namespace ShardingCore.Extensions var contextModel = dbContext.Model as Model; #endif -#if EFCORE6 +#if EFCORE6|| EFCORE7 var contextModelRelationalModel = contextModel.GetRelationalModel() as RelationalModel; contextModelRelationalModel.Tables.Clear(); #endif diff --git a/src/ShardingCore/ShardingCore.csproj b/src/ShardingCore/ShardingCore.csproj index 967d686a..7841de39 100644 --- a/src/ShardingCore/ShardingCore.csproj +++ b/src/ShardingCore/ShardingCore.csproj @@ -1,7 +1,7 @@  net6.0 - 7.7.0.11 + $(EFCORE7) true TRACE;DEBUG;EFCORE7; latest diff --git a/src2/ShardingCore2/ShardingCore2.csproj b/src2/ShardingCore2/ShardingCore2.csproj index 12b523ac..9991f715 100644 --- a/src2/ShardingCore2/ShardingCore2.csproj +++ b/src2/ShardingCore2/ShardingCore2.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 7.2.0.11 + $(EFCORE2) true TRACE;DEBUG;EFCORE2; 9.0 diff --git a/src3/ShardingCore3/ShardingCore3.csproj b/src3/ShardingCore3/ShardingCore3.csproj index d7d0da04..7bfb0be2 100644 --- a/src3/ShardingCore3/ShardingCore3.csproj +++ b/src3/ShardingCore3/ShardingCore3.csproj @@ -1,7 +1,7 @@  netstandard2.0 - 7.3.0.11 + $(EFCORE3) true TRACE;DEBUG;EFCORE3; 9.0 diff --git a/src5/ShardingCore5/ShardingCore5.csproj b/src5/ShardingCore5/ShardingCore5.csproj index 84209a90..3c222f1a 100644 --- a/src5/ShardingCore5/ShardingCore5.csproj +++ b/src5/ShardingCore5/ShardingCore5.csproj @@ -2,7 +2,7 @@ netstandard2.1 - 7.5.0.11 + $(EFCORE5) true TRACE;DEBUG;EFCORE5; 9.0 diff --git a/src6/ShardingCore6/ShardingCore6.csproj b/src6/ShardingCore6/ShardingCore6.csproj index 7386a7c0..7d3877ac 100644 --- a/src6/ShardingCore6/ShardingCore6.csproj +++ b/src6/ShardingCore6/ShardingCore6.csproj @@ -2,7 +2,7 @@ net6.0 - 7.6.0.11 + $(EFCORE6) true TRACE;DEBUG;EFCORE6; 9.0