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

Diff for: src/EFCore.Design/Properties/DesignStrings.Designer.cs

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/EFCore.Design/Properties/DesignStrings.resx

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

Diff for: src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs

-8
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;

Diff for: src/EFCore.InMemory/Design/Internal/InMemoryCSharpRuntimeAnnotationCodeGenerator.cs

+17
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
}

Diff for: src/EFCore.InMemory/EFCore.InMemory.csproj

+1-1
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>

Diff for: src/EFCore.InMemory/Extensions/InMemoryEntityTypeBuilderExtensions.cs

+1-5
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
}

Diff for: src/EFCore.InMemory/Extensions/InMemoryEntityTypeExtensions.cs

+5-21
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
}

Diff for: src/EFCore.InMemory/Extensions/InMemoryServiceCollectionExtensions.cs

-1
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;

Diff for: src/EFCore.InMemory/Metadata/Conventions/InMemoryConventionSetBuilder.cs

+1-1
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.
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+
}

Diff for: src/EFCore.InMemory/Properties/InMemoryStrings.Designer.cs

+10-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<#
22
Session = new System.Collections.Generic.Dictionary<string, object>();
33
Session["ResourceFile"] = "InMemoryStrings.resx";
4-
Session["ResourceNamespace"] = "Microsoft.EntityFrameworkCore.InMemory.Properties";
4+
Session["ResourceNamespace"] = "Microsoft.EntityFrameworkCore.Properties";
55
Session["LoggingDefinitionsClass"] = "Diagnostics.Internal.InMemoryLoggingDefinitions";
66
#>
77
<#@ include file="..\..\..\tools\Resources.tt" #>

Diff for: src/EFCore.InMemory/Properties/InMemoryStrings.resx

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<data name="CompiledModelDefiningQuery" xml:space="preserve">
121+
<value>The entity type '{entityType}' has a defining query configured. Compiled model can't be generated, because defining queries are not supported.</value>
122+
</data>
120123
<data name="DefaultIfEmptyAppliedAfterProjection" xml:space="preserve">
121124
<value>Cannot apply 'DefaultIfEmpty' after a client-evaluated projection. Consider applying 'DefaultIfEmpty' before last 'Select' or use 'AsEnumerable' before 'DefaultIfEmpty' to apply it on client-side.</value>
122125
</data>

Diff for: src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs

-6
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ public static class RelationalEntityTypeExtensions
3939

4040
return ((entityType as IConventionEntityType)?.GetViewNameConfigurationSource() == null)
4141
&& (entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null
42-
#pragma warning disable CS0618 // Type or member is obsolete
43-
&& (entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null
44-
#pragma warning restore CS0618 // Type or member is obsolete
4542
&& (entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null
4643
? GetDefaultTableName(entityType)
4744
: null;
@@ -267,9 +264,6 @@ public static void SetSchema(this IMutableEntityType entityType, string? value)
267264
}
268265

269266
return ((entityType as IConventionEntityType)?.GetFunctionNameConfigurationSource() == null)
270-
#pragma warning disable CS0618 // Type or member is obsolete
271-
&& ((entityType as IConventionEntityType)?.GetDefiningQueryConfigurationSource() == null)
272-
#pragma warning restore CS0618 // Type or member is obsolete
273267
&& ((entityType as IConventionEntityType)?.GetSqlQueryConfigurationSource() == null)
274268
? GetDefaultViewName(entityType)
275269
: null;

Diff for: src/EFCore.Relational/Metadata/Conventions/RelationalQueryFilterRewritingConvention.cs

-8
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ public override void ProcessModelFinalizing(
3939
{
4040
entityType.SetQueryFilter((LambdaExpression)DbSetAccessRewriter.Rewrite(modelBuilder.Metadata, queryFilter));
4141
}
42-
43-
#pragma warning disable CS0618 // Type or member is obsolete
44-
var definingQuery = ((IEntityType)entityType).GetDefiningQuery();
45-
if (definingQuery != null)
46-
{
47-
entityType.SetDefiningQuery((LambdaExpression)DbSetAccessRewriter.Rewrite(modelBuilder.Metadata, definingQuery));
48-
}
49-
#pragma warning restore CS0618 // Type or member is obsolete
5042
}
5143
}
5244

Diff for: src/EFCore/Extensions/ConventionEntityTypeExtensions.cs

-38
This file was deleted.

Diff for: src/EFCore/Extensions/EntityTypeExtensions.cs

-23
This file was deleted.

Diff for: src/EFCore/Extensions/MutableEntityTypeExtensions.cs

-25
This file was deleted.

0 commit comments

Comments
 (0)