This commit is contained in:
xuejiaming 2022-12-23 15:20:36 +08:00
parent d1e6beb9d1
commit a1ca244ccb
7 changed files with 24 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>7.7.0.11</Version>
<Version>$(EFCORE7)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE7;</DefineConstants>
<LangVersion>latest</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.2.0.11</Version>
<Version>$(EFCORE2)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE2;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>7.3.0.11</Version>
<Version>$(EFCORE3)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE3;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>7.5.0.11</Version>
<Version>$(EFCORE5)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE5;</DefineConstants>
<LangVersion>9.0</LangVersion>

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>7.6.0.11</Version>
<Version>$(EFCORE6)</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<DefineConstants>TRACE;DEBUG;EFCORE6;</DefineConstants>
<LangVersion>9.0</LangVersion>