Skip to content

Commit ce01986

Browse files
authored
Remove Obsolete members from EF 8 (#35845)
Fixes #34467
1 parent 613a9b3 commit ce01986

File tree

34 files changed

+200
-533
lines changed

34 files changed

+200
-533
lines changed

src/EFCore.Design/Properties/DesignStrings.Designer.cs

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/EFCore.Design/Properties/DesignStrings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,6 @@
162162
<data name="CompiledModelCustomCacheKeyFactory" xml:space="preserve">
163163
<value>The context is configured to use a custom model cache key factory '{factoryType}', this usually indicates that the produced model can change between context instances. To preserve this behavior manually modify the generated compiled model source code.</value>
164164
</data>
165-
<data name="CompiledModelDefiningQuery" xml:space="preserve">
166-
<value>The entity type '{entityType}' has a defining query configured. Compiled model can't be generated, because defining queries are not supported.</value>
167-
</data>
168165
<data name="CompiledModelGenerated" xml:space="preserve">
169166
<value>Successfully generated a compiled model, it will be discovered automatically, but you can also call '{optionsCall}'. Run this command again when the model is modified.</value>
170167
</data>

src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,6 @@ private void Create(IEntityType entityType, CSharpRuntimeAnnotationCodeGenerator
898898
throw new InvalidOperationException(DesignStrings.CompiledModelQueryFilter(entityType.ShortName()));
899899
}
900900

901-
#pragma warning disable CS0618 // Type or member is obsolete
902-
if (entityType.GetDefiningQuery() != null)
903-
{
904-
// TODO: Move to InMemoryCSharpRuntimeAnnotationCodeGenerator, see #21624
905-
throw new InvalidOperationException(DesignStrings.CompiledModelDefiningQuery(entityType.ShortName()));
906-
}
907-
#pragma warning restore CS0618 // Type or member is obsolete
908-
909901
AddNamespace(entityType.ClrType, parameters.Namespaces);
910902

911903
var mainBuilder = parameters.MainBuilder;

src/EFCore.InMemory/Design/Internal/InMemoryCSharpRuntimeAnnotationCodeGenerator.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.EntityFrameworkCore.Design.Internal;
5+
using Microsoft.EntityFrameworkCore.InMemory.Internal;
56

67
namespace Microsoft.EntityFrameworkCore.InMemory.Design.Internal;
78

@@ -25,4 +26,20 @@ public InMemoryCSharpRuntimeAnnotationCodeGenerator(
2526
: base(dependencies)
2627
{
2728
}
29+
30+
/// <summary>
31+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
32+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
33+
/// any release. You should only use it directly in your code with extreme caution and knowing that
34+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
35+
/// </summary>
36+
public override void Generate(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters)
37+
{
38+
if (entityType.GetInMemoryQuery() != null)
39+
{
40+
throw new InvalidOperationException(InMemoryStrings.CompiledModelDefiningQuery(entityType.DisplayName()));
41+
}
42+
43+
base.Generate(entityType, parameters);
44+
}
2845
}

src/EFCore.InMemory/EFCore.InMemory.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<MinClientVersion>3.6</MinClientVersion>
77
<AssemblyName>Microsoft.EntityFrameworkCore.InMemory</AssemblyName>
8-
<RootNamespace>Microsoft.EntityFrameworkCore.InMemory</RootNamespace>
8+
<RootNamespace>Microsoft.EntityFrameworkCore</RootNamespace>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<PackageTags>$(PackageTags);In-Memory</PackageTags>
1111
<ImplicitUsings>true</ImplicitUsings>

src/EFCore.InMemory/Extensions/InMemoryEntityTypeBuilderExtensions.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,5 @@ public static bool CanSetInMemoryQuery(
101101
this IConventionEntityTypeBuilder entityTypeBuilder,
102102
LambdaExpression? query,
103103
bool fromDataAnnotation = false)
104-
#pragma warning disable EF1001 // Internal EF Core API usage.
105-
#pragma warning disable CS0612 // Type or member is obsolete
106-
=> entityTypeBuilder.CanSetAnnotation(CoreAnnotationNames.DefiningQuery, query, fromDataAnnotation);
107-
#pragma warning restore CS0612 // Type or member is obsolete
108-
#pragma warning restore EF1001 // Internal EF Core API usage.
104+
=> entityTypeBuilder.CanSetAnnotation(InMemoryAnnotationNames.DefiningQuery, query, fromDataAnnotation);
109105
}

src/EFCore.InMemory/Extensions/InMemoryEntityTypeExtensions.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ public static class InMemoryEntityTypeExtensions
2121
/// <param name="entityType">The entity type to get the in-memory query for.</param>
2222
/// <returns>The LINQ query used as the default source.</returns>
2323
public static LambdaExpression? GetInMemoryQuery(this IReadOnlyEntityType entityType)
24-
#pragma warning disable EF1001 // Internal EF Core API usage.
25-
#pragma warning disable CS0612 // Type or member is obsolete
26-
=> (LambdaExpression?)entityType[CoreAnnotationNames.DefiningQuery];
27-
#pragma warning restore CS0612 // Type or member is obsolete
28-
#pragma warning restore EF1001 // Internal EF Core API usage.
24+
=> (LambdaExpression?)entityType[InMemoryAnnotationNames.DefiningQuery];
2925

3026
/// <summary>
3127
/// Sets the LINQ query used as the default source for queries of this type.
@@ -36,11 +32,7 @@ public static void SetInMemoryQuery(
3632
this IMutableEntityType entityType,
3733
LambdaExpression? inMemoryQuery)
3834
=> entityType
39-
#pragma warning disable EF1001 // Internal EF Core API usage.
40-
#pragma warning disable CS0612 // Type or member is obsolete
41-
.SetOrRemoveAnnotation(CoreAnnotationNames.DefiningQuery, inMemoryQuery);
42-
#pragma warning restore CS0612 // Type or member is obsolete
43-
#pragma warning restore EF1001 // Internal EF Core API usage.
35+
.SetOrRemoveAnnotation(InMemoryAnnotationNames.DefiningQuery, inMemoryQuery);
4436

4537
/// <summary>
4638
/// Sets the LINQ query used as the default source for queries of this type.
@@ -54,22 +46,14 @@ public static void SetInMemoryQuery(
5446
LambdaExpression? inMemoryQuery,
5547
bool fromDataAnnotation = false)
5648
=> (LambdaExpression?)entityType
57-
#pragma warning disable EF1001 // Internal EF Core API usage.
58-
#pragma warning disable CS0612 // Type or member is obsolete
59-
.SetOrRemoveAnnotation(CoreAnnotationNames.DefiningQuery, inMemoryQuery, fromDataAnnotation)
60-
#pragma warning restore CS0612 // Type or member is obsolete
61-
#pragma warning restore EF1001 // Internal EF Core API usage.
49+
.SetOrRemoveAnnotation(InMemoryAnnotationNames.DefiningQuery, inMemoryQuery, fromDataAnnotation)
6250
?.Value;
6351

6452
/// <summary>
6553
/// Returns the configuration source for <see cref="GetInMemoryQuery" />.
6654
/// </summary>
6755
/// <param name="entityType">The entity type.</param>
6856
/// <returns>The configuration source for <see cref="GetInMemoryQuery" />.</returns>
69-
public static ConfigurationSource? GetDefiningQueryConfigurationSource(this IConventionEntityType entityType)
70-
#pragma warning disable EF1001 // Internal EF Core API usage.
71-
#pragma warning disable CS0612 // Type or member is obsolete
72-
=> entityType.FindAnnotation(CoreAnnotationNames.DefiningQuery)?.GetConfigurationSource();
73-
#pragma warning restore CS0612 // Type or member is obsolete
74-
#pragma warning restore EF1001 // Internal EF Core API usage.
57+
public static ConfigurationSource? GetInMemoryQueryConfigurationSource(this IConventionEntityType entityType)
58+
=> entityType.FindAnnotation(InMemoryAnnotationNames.DefiningQuery)?.GetConfigurationSource();
7559
}

src/EFCore.InMemory/Extensions/InMemoryServiceCollectionExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.ComponentModel;
55
using Microsoft.EntityFrameworkCore.InMemory.Diagnostics.Internal;
66
using Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal;
7-
using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions;
87
using Microsoft.EntityFrameworkCore.InMemory.Query.Internal;
98
using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal;
109
using Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal;

src/EFCore.InMemory/Metadata/Conventions/InMemoryConventionSetBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
namespace Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions;
4+
namespace Microsoft.EntityFrameworkCore.Metadata.Conventions;
55

66
/// <summary>
77
/// A builder for building conventions for th in-memory provider.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
namespace Microsoft.EntityFrameworkCore.Metadata.Internal;
5+
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>
12+
public static class InMemoryAnnotationNames
13+
{
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>
20+
public const string Prefix = "InMemory:";
21+
22+
/// <summary>
23+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
24+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
25+
/// any release. You should only use it directly in your code with extreme caution and knowing that
26+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
27+
/// </summary>
28+
public const string DefiningQuery = Prefix + "DefiningQuery";
29+
}

0 commit comments

Comments
 (0)