Skip to content

Commit fba2c45

Browse files
committed
feat:升级8.0
1 parent ba2faa3 commit fba2c45

File tree

241 files changed

+21556
-10114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+21556
-10114
lines changed

Directory.Build.props

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>6.0.22</VersionPrefix>
4-
<TargetFramework>net6.0</TargetFramework>
3+
<VersionPrefix>8.0.0</VersionPrefix>
4+
<TargetFramework>net8.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<AnalysisLevel>latest</AnalysisLevel>
@@ -13,10 +13,41 @@
1313
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Npgsql.snk</AssemblyOriginatorKeyFile>
1414
<SignAssembly>true</SignAssembly>
1515
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
16+
<ImplicitUsings>true</ImplicitUsings>
1617
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1718
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1819
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
1920
<PackageProjectUrl>https://github.com/dotnetcore/EntityFrameworkCore.KingbaseES</PackageProjectUrl>
2021
</PropertyGroup>
22+
23+
<ItemGroup>
24+
<Using Include="System.Diagnostics" />
25+
<Using Include="System.Linq.Expressions" />
26+
<Using Include="System.Reflection" />
27+
<Using Include="Microsoft.EntityFrameworkCore" />
28+
<Using Include="Microsoft.EntityFrameworkCore.ChangeTracking" />
29+
<Using Include="Microsoft.EntityFrameworkCore.Diagnostics" />
30+
<Using Include="Microsoft.EntityFrameworkCore.Design" />
31+
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
32+
<Using Include="Microsoft.EntityFrameworkCore.Infrastructure" />
33+
<Using Include="Microsoft.EntityFrameworkCore.Metadata" />
34+
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Conventions" />
35+
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure" />
36+
<Using Include="Microsoft.EntityFrameworkCore.Migrations" />
37+
<Using Include="Microsoft.EntityFrameworkCore.Migrations.Operations" />
38+
<Using Include="Microsoft.EntityFrameworkCore.Query" />
39+
<Using Include="Microsoft.EntityFrameworkCore.Query.SqlExpressions" />
40+
<Using Include="Microsoft.EntityFrameworkCore.Scaffolding" />
41+
<Using Include="Microsoft.EntityFrameworkCore.Scaffolding.Metadata" />
42+
<Using Include="Microsoft.EntityFrameworkCore.Storage" />
43+
<Using Include="Microsoft.EntityFrameworkCore.Storage.ValueConversion" />
44+
<Using Include="Microsoft.EntityFrameworkCore.Update" />
45+
<Using Include="Microsoft.EntityFrameworkCore.ValueGeneration" />
46+
<Using Include="Microsoft.EntityFrameworkCore.Utilities" />
47+
<Using Include="Microsoft.Extensions.Logging" />
48+
<Using Include="Microsoft.Extensions.DependencyInjection" />
49+
<Using Include="Kdbndp" />
50+
<Using Include="KdbndpTypes" />
51+
</ItemGroup>
2152

2253
</Project>

Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project>
22
<PropertyGroup>
3-
<EFCoreVersion>6.0.22</EFCoreVersion>
4-
<MicrosoftExtensionsVersion>6.0.0</MicrosoftExtensionsVersion>
3+
<EFCoreVersion>8.0.0</EFCoreVersion>
4+
<MicrosoftExtensionsVersion>8.0.0</MicrosoftExtensionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="JetBrains.Annotations" Version="2023.2.0" />
8-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="6.0.22" />
8+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />
99
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
1010
<PackageVersion Include="Microsoft.EntityFrameworkCore.Abstractions" Version="$(EFCoreVersion)" />
1111
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />

src/EFCore.KingbaseES/Design/Internal/KdbndpAnnotationCodeGenerator.cs

Lines changed: 197 additions & 110 deletions
Large diffs are not rendered by default.
Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.EntityFrameworkCore.Design.Internal;
5+
using Kdbndp.EntityFrameworkCore.KingbaseES.Metadata.Internal;
6+
using Kdbndp.EntityFrameworkCore.KingbaseES.Storage.Internal.Mapping;
7+
8+
namespace Kdbndp.EntityFrameworkCore.KingbaseES.Design.Internal;
9+
10+
/// <summary>
11+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
12+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
13+
/// any release. You should only use it directly in your code with extreme caution and knowing that
14+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
15+
/// </summary>
16+
#pragma warning disable EF1001 // Internal EF Core API usage.
17+
public class KdbndpCSharpRuntimeAnnotationCodeGenerator : RelationalCSharpRuntimeAnnotationCodeGenerator
18+
{
19+
/// <summary>
20+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
21+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
22+
/// any release. You should only use it directly in your code with extreme caution and knowing that
23+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
24+
/// </summary>
25+
public KdbndpCSharpRuntimeAnnotationCodeGenerator(
26+
CSharpRuntimeAnnotationCodeGeneratorDependencies dependencies,
27+
RelationalCSharpRuntimeAnnotationCodeGeneratorDependencies relationalDependencies)
28+
: base(dependencies, relationalDependencies)
29+
{
30+
}
31+
32+
/// <summary>
33+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
34+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
35+
/// any release. You should only use it directly in your code with extreme caution and knowing that
36+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
37+
/// </summary>
38+
public override bool Create(
39+
CoreTypeMapping typeMapping,
40+
CSharpRuntimeAnnotationCodeGeneratorParameters parameters,
41+
ValueComparer? valueComparer = null,
42+
ValueComparer? keyValueComparer = null,
43+
ValueComparer? providerValueComparer = null)
44+
{
45+
var result = base.Create(typeMapping, parameters, valueComparer, keyValueComparer, providerValueComparer);
46+
47+
var mainBuilder = parameters.MainBuilder;
48+
49+
var KdbndpDbTypeBasedDefaultInstance = typeMapping switch
50+
{
51+
KdbndpStringTypeMapping => KdbndpStringTypeMapping.Default,
52+
// KdbndpMultirangeTypeMapping => KdbndpMultirangeTypeMapping.Default,
53+
_ => (IKdbndpTypeMapping?)null
54+
};
55+
56+
if (KdbndpDbTypeBasedDefaultInstance is not null)
57+
{
58+
var KdbndpDbType = ((IKdbndpTypeMapping)typeMapping).KdbndpDbType;
59+
60+
if (KdbndpDbType != KdbndpDbTypeBasedDefaultInstance.KdbndpDbType)
61+
{
62+
mainBuilder.AppendLine(";");
63+
64+
mainBuilder.Append(
65+
$"{parameters.TargetName}.TypeMapping = (({typeMapping.GetType().Name}){parameters.TargetName}.TypeMapping).Clone(KdbndpDbType: ");
66+
67+
mainBuilder
68+
.Append(nameof(KdbndpTypes))
69+
.Append(".")
70+
.Append(nameof(KdbndpDbType))
71+
.Append(".")
72+
.Append(KdbndpDbType.ToString());
73+
74+
mainBuilder
75+
.Append(")")
76+
.DecrementIndent();
77+
}
78+
79+
}
80+
81+
switch (typeMapping)
82+
{
83+
#pragma warning disable CS0618 // KdbndpConnection.GlobalTypeMapper is obsolete
84+
case KdbndpEnumTypeMapping enumTypeMapping:
85+
if (enumTypeMapping.NameTranslator != KdbndpConnection.GlobalTypeMapper.DefaultNameTranslator)
86+
{
87+
throw new NotSupportedException(
88+
"Mapped enums are only supported in the compiled model if they use the default name translator");
89+
}
90+
break;
91+
#pragma warning restore CS0618
92+
}
93+
94+
return result;
95+
}
96+
97+
/// <inheritdoc />
98+
public override void Generate(IModel model, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
99+
{
100+
if (!parameters.IsRuntime)
101+
{
102+
var annotations = parameters.Annotations;
103+
annotations.Remove(KdbndpAnnotationNames.DatabaseTemplate);
104+
annotations.Remove(KdbndpAnnotationNames.Tablespace);
105+
annotations.Remove(KdbndpAnnotationNames.CollationDefinitionPrefix);
106+
107+
#pragma warning disable CS0618
108+
annotations.Remove(KdbndpAnnotationNames.DefaultColumnCollation);
109+
#pragma warning restore CS0618
110+
111+
foreach (var annotationName in annotations.Keys.Where(
112+
k =>
113+
k.StartsWith(KdbndpAnnotationNames.PostgresExtensionPrefix, StringComparison.Ordinal)
114+
|| k.StartsWith(KdbndpAnnotationNames.EnumPrefix, StringComparison.Ordinal)
115+
|| k.StartsWith(KdbndpAnnotationNames.RangePrefix, StringComparison.Ordinal)))
116+
{
117+
annotations.Remove(annotationName);
118+
}
119+
}
120+
121+
base.Generate(model, parameters);
122+
}
123+
124+
/// <inheritdoc />
125+
public override void Generate(IRelationalModel model, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
126+
{
127+
if (!parameters.IsRuntime)
128+
{
129+
var annotations = parameters.Annotations;
130+
annotations.Remove(KdbndpAnnotationNames.DatabaseTemplate);
131+
annotations.Remove(KdbndpAnnotationNames.Tablespace);
132+
annotations.Remove(KdbndpAnnotationNames.CollationDefinitionPrefix);
133+
134+
#pragma warning disable CS0618
135+
annotations.Remove(KdbndpAnnotationNames.DefaultColumnCollation);
136+
#pragma warning restore CS0618
137+
138+
foreach (var annotationName in annotations.Keys.Where(
139+
k =>
140+
k.StartsWith(KdbndpAnnotationNames.PostgresExtensionPrefix, StringComparison.Ordinal)
141+
|| k.StartsWith(KdbndpAnnotationNames.EnumPrefix, StringComparison.Ordinal)
142+
|| k.StartsWith(KdbndpAnnotationNames.RangePrefix, StringComparison.Ordinal)))
143+
{
144+
annotations.Remove(annotationName);
145+
}
146+
}
147+
148+
base.Generate(model, parameters);
149+
}
150+
151+
/// <inheritdoc />
152+
public override void Generate(IProperty property, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
153+
{
154+
if (!parameters.IsRuntime)
155+
{
156+
var annotations = parameters.Annotations;
157+
annotations.Remove(KdbndpAnnotationNames.IdentityOptions);
158+
annotations.Remove(KdbndpAnnotationNames.TsVectorConfig);
159+
annotations.Remove(KdbndpAnnotationNames.TsVectorProperties);
160+
annotations.Remove(KdbndpAnnotationNames.CompressionMethod);
161+
162+
if (!annotations.ContainsKey(KdbndpAnnotationNames.ValueGenerationStrategy))
163+
{
164+
annotations[KdbndpAnnotationNames.ValueGenerationStrategy] = property.GetValueGenerationStrategy();
165+
}
166+
}
167+
168+
base.Generate(property, parameters);
169+
}
170+
171+
/// <inheritdoc />
172+
public override void Generate(IColumn column, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
173+
{
174+
if (!parameters.IsRuntime)
175+
{
176+
var annotations = parameters.Annotations;
177+
178+
annotations.Remove(KdbndpAnnotationNames.IdentityOptions);
179+
annotations.Remove(KdbndpAnnotationNames.TsVectorConfig);
180+
annotations.Remove(KdbndpAnnotationNames.TsVectorProperties);
181+
annotations.Remove(KdbndpAnnotationNames.CompressionMethod);
182+
}
183+
184+
base.Generate(column, parameters);
185+
}
186+
187+
/// <inheritdoc />
188+
public override void Generate(IIndex index, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
189+
{
190+
if (!parameters.IsRuntime)
191+
{
192+
var annotations = parameters.Annotations;
193+
194+
annotations.Remove(KdbndpAnnotationNames.IndexMethod);
195+
annotations.Remove(KdbndpAnnotationNames.IndexOperators);
196+
annotations.Remove(KdbndpAnnotationNames.IndexSortOrder);
197+
annotations.Remove(KdbndpAnnotationNames.IndexNullSortOrder);
198+
annotations.Remove(KdbndpAnnotationNames.IndexInclude);
199+
annotations.Remove(KdbndpAnnotationNames.CreatedConcurrently);
200+
annotations.Remove(KdbndpAnnotationNames.NullsDistinct);
201+
202+
foreach (var annotationName in annotations.Keys.Where(
203+
k => k.StartsWith(KdbndpAnnotationNames.StorageParameterPrefix, StringComparison.Ordinal)))
204+
{
205+
annotations.Remove(annotationName);
206+
}
207+
}
208+
209+
base.Generate(index, parameters);
210+
}
211+
212+
/// <inheritdoc />
213+
public override void Generate(ITableIndex index, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
214+
{
215+
if (!parameters.IsRuntime)
216+
{
217+
var annotations = parameters.Annotations;
218+
219+
annotations.Remove(KdbndpAnnotationNames.IndexMethod);
220+
annotations.Remove(KdbndpAnnotationNames.IndexOperators);
221+
annotations.Remove(KdbndpAnnotationNames.IndexSortOrder);
222+
annotations.Remove(KdbndpAnnotationNames.IndexNullSortOrder);
223+
annotations.Remove(KdbndpAnnotationNames.IndexInclude);
224+
annotations.Remove(KdbndpAnnotationNames.CreatedConcurrently);
225+
annotations.Remove(KdbndpAnnotationNames.NullsDistinct);
226+
227+
foreach (var annotationName in annotations.Keys.Where(
228+
k => k.StartsWith(KdbndpAnnotationNames.StorageParameterPrefix, StringComparison.Ordinal)))
229+
{
230+
annotations.Remove(annotationName);
231+
}
232+
}
233+
234+
base.Generate(index, parameters);
235+
}
236+
237+
/// <inheritdoc />
238+
public override void Generate(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
239+
{
240+
if (!parameters.IsRuntime)
241+
{
242+
var annotations = parameters.Annotations;
243+
244+
annotations.Remove(KdbndpAnnotationNames.UnloggedTable);
245+
annotations.Remove(CockroachDbAnnotationNames.InterleaveInParent);
246+
247+
foreach (var annotationName in annotations.Keys.Where(
248+
k => k.StartsWith(KdbndpAnnotationNames.StorageParameterPrefix, StringComparison.Ordinal)))
249+
{
250+
annotations.Remove(annotationName);
251+
}
252+
}
253+
254+
base.Generate(entityType, parameters);
255+
}
256+
257+
/// <inheritdoc />
258+
public override void Generate(ITable table, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
259+
{
260+
if (!parameters.IsRuntime)
261+
{
262+
var annotations = parameters.Annotations;
263+
264+
annotations.Remove(KdbndpAnnotationNames.UnloggedTable);
265+
annotations.Remove(CockroachDbAnnotationNames.InterleaveInParent);
266+
267+
foreach (var annotationName in annotations.Keys.Where(
268+
k => k.StartsWith(KdbndpAnnotationNames.StorageParameterPrefix, StringComparison.Ordinal)))
269+
{
270+
annotations.Remove(annotationName);
271+
}
272+
}
273+
274+
base.Generate(table, parameters);
275+
}
276+
}

src/EFCore.KingbaseES/Design/Internal/KdbndpDesignTimeServices.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
1-
using Microsoft.EntityFrameworkCore.Design;
2-
using Microsoft.EntityFrameworkCore.Scaffolding;
3-
using Microsoft.EntityFrameworkCore.Utilities;
4-
using Microsoft.Extensions.DependencyInjection;
1+
using Microsoft.EntityFrameworkCore.Design.Internal;
52
using Kdbndp.EntityFrameworkCore.KingbaseES.Scaffolding.Internal;
63

74
namespace Kdbndp.EntityFrameworkCore.KingbaseES.Design.Internal;
85

6+
/// <summary>
7+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
8+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
9+
/// any release. You should only use it directly in your code with extreme caution and knowing that
10+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
11+
/// </summary>
912
public class KdbndpDesignTimeServices : IDesignTimeServices
1013
{
14+
/// <summary>
15+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
16+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
17+
/// any release. You should only use it directly in your code with extreme caution and knowing that
18+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
19+
/// </summary>
1120
public virtual void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
1221
{
1322
Check.NotNull(serviceCollection, nameof(serviceCollection));
1423

1524
serviceCollection.AddEntityFrameworkKdbndp();
25+
#pragma warning disable EF1001 // Internal EF Core API usage.
1626
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
27+
.TryAdd<ICSharpRuntimeAnnotationCodeGenerator, KdbndpCSharpRuntimeAnnotationCodeGenerator>()
28+
#pragma warning restore EF1001 // Internal EF Core API usage.
1729
.TryAdd<IAnnotationCodeGenerator, KdbndpAnnotationCodeGenerator>()
1830
.TryAdd<IDatabaseModelFactory, KdbndpDatabaseModelFactory>()
1931
.TryAdd<IProviderConfigurationCodeGenerator, KdbndpCodeGenerator>()

0 commit comments

Comments
 (0)