Skip to content

Commit 9e69e25

Browse files
authored
EF-165: Add experimental build target for EF-9 (#176)
1 parent 2de7bc5 commit 9e69e25

20 files changed

+447
-34
lines changed

Diff for: MongoDB.EFCoreProvider.sln

+15
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,41 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
README.md = README.md
1818
THIRD-PARTY-NOTICES = THIRD-PARTY-NOTICES
1919
src\Directory.Build.props = src\Directory.Build.props
20+
tests\Directory.Build.props = tests\Directory.Build.props
2021
EndProjectSection
2122
EndProject
2223
Global
2324
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2425
Debug|Any CPU = Debug|Any CPU
2526
Release|Any CPU = Release|Any CPU
27+
Debug EF9|Any CPU = Debug EF9|Any CPU
28+
Release EF9|Any CPU = Release EF9|Any CPU
2629
EndGlobalSection
2730
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2831
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2932
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
3033
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
3134
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Debug EF9|Any CPU.ActiveCfg = Debug EF9|Any CPU
36+
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Debug EF9|Any CPU.Build.0 = Debug EF9|Any CPU
37+
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Release EF9|Any CPU.ActiveCfg = Release EF9|Any CPU
38+
{F50A0110-A930-4876-BBD4-78B039C12D9E}.Release EF9|Any CPU.Build.0 = Release EF9|Any CPU
3239
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3340
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
3441
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
3542
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Debug EF9|Any CPU.ActiveCfg = Debug EF9|Any CPU
44+
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Debug EF9|Any CPU.Build.0 = Debug EF9|Any CPU
45+
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Release EF9|Any CPU.ActiveCfg = Release EF9|Any CPU
46+
{9337C5E2-A5DB-4608-9274-5C679B92ED9E}.Release EF9|Any CPU.Build.0 = Release EF9|Any CPU
3647
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3748
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Debug|Any CPU.Build.0 = Debug|Any CPU
3849
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Release|Any CPU.ActiveCfg = Release|Any CPU
3950
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Release|Any CPU.Build.0 = Release|Any CPU
51+
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Debug EF9|Any CPU.ActiveCfg = Debug EF9|Any CPU
52+
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Debug EF9|Any CPU.Build.0 = Debug EF9|Any CPU
53+
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Release EF9|Any CPU.ActiveCfg = Release EF9|Any CPU
54+
{CDBD7CC4-0F4D-4B03-859E-71FE5A3DE363}.Release EF9|Any CPU.Build.0 = Release EF9|Any CPU
4055
EndGlobalSection
4156
GlobalSection(SolutionProperties) = preSolution
4257
HideSolutionNode = FALSE

Diff for: src/MongoDB.EntityFrameworkCore/ChangeTracking/ListOfNullableValueTypesComparer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Originally from EFCore 9's ListOfNullableValueTypesComparer.cs
55

6+
#if !EF9
67
using System;
78
using System.Collections.Generic;
89
using System.Collections.ObjectModel;
@@ -217,3 +218,4 @@ private static int GetHashCode(IEnumerable<TElement?> source, ValueComparer<TEle
217218
}
218219
}
219220
}
221+
#endif

Diff for: src/MongoDB.EntityFrameworkCore/ChangeTracking/ListOfReferenceTypesComparer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Originally from EFCore 9's ListOfReferenceTypesComparer.cs
55

6+
#if !EF9
67
using System;
78
using System.Collections;
89
using System.Collections.Generic;
@@ -213,3 +214,4 @@ private static int GetHashCode(IEnumerable source, ValueComparer elementComparer
213214
}
214215
}
215216
}
217+
#endif

Diff for: src/MongoDB.EntityFrameworkCore/ChangeTracking/ListOfValueTypesComparer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// Originally from EFCore 9's ListOfValueTypesComparer.cs
55

6+
#if !EF9
67
using System;
78
using System.Collections.Generic;
89
using System.Collections.ObjectModel;
@@ -202,3 +203,4 @@ private static IList<TElement> Snapshot(IEnumerable<TElement> source, ValueCompa
202203
}
203204
}
204205
}
206+
#endif

Diff for: src/MongoDB.EntityFrameworkCore/Metadata/Conventions/BsonAttributes/BsonIgnoreAttributeConvention.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@
1919
using Microsoft.EntityFrameworkCore.Metadata.Builders;
2020
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
2121
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
22-
using Microsoft.EntityFrameworkCore.Metadata.Internal;
2322
using MongoDB.Bson.Serialization.Attributes;
23+
#if EF9
24+
using Microsoft.EntityFrameworkCore.Internal;
25+
#else
26+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
27+
#endif
2428

2529
namespace MongoDB.EntityFrameworkCore.Metadata.Conventions.BsonAttributes;
2630

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
4-
<Description>Official MongoDB supported provider for Entity Framework Core 8. See https://www.mongodb.com/docs/entity-framework/ for more details.</Description>
4+
<Description>Official MongoDB supported provider for Entity Framework Core. See https://www.mongodb.com/docs/entity-framework/ for more details.</Description>
55
<IsPackable>true</IsPackable>
66
<PackageId>MongoDB.EntityFrameworkCore</PackageId>
7-
<Configurations>Debug;Release;</Configurations>
7+
<Configurations>Debug;Release;Debug EF9;Release EF9</Configurations>
88
<Platforms>AnyCPU</Platforms>
99
</PropertyGroup>
1010

@@ -16,11 +16,28 @@
1616
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
1717
<DocumentationFile>bin\Debug\MongoDB.EntityFrameworkCore.xml</DocumentationFile>
1818
</PropertyGroup>
19-
19+
20+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug EF9' ">
21+
<DefineConstants>TRACE;DEBUG;EF9</DefineConstants>
22+
<DebugSymbols>true</DebugSymbols>
23+
</PropertyGroup>
24+
25+
<PropertyGroup Condition=" '$(Configuration)' == 'Release EF9' ">
26+
<DefineConstants>TRACE;RELEASE;EF9</DefineConstants>
27+
<Optimize>true</Optimize>
28+
</PropertyGroup>
29+
30+
<ItemGroup Condition=" '$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug' ">
31+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
32+
</ItemGroup>
33+
34+
<ItemGroup Condition=" '$(Configuration)' == 'Release EF9' Or '$(Configuration)' == 'Debug EF9' ">
35+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
36+
</ItemGroup>
37+
2038
<ItemGroup>
2139
<InternalsVisibleTo Include="MongoDB.EntityFrameworkCore.UnitTests" />
2240
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
23-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
2441
<PackageReference Remove="Microsoft.SourceLink.GitHub" />
2542
</ItemGroup>
2643
</Project>

Diff for: src/MongoDB.EntityFrameworkCore/Query/QueryingEnumerable.cs

+11-19
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,9 @@ public bool MoveNext()
9898
{
9999
try
100100
{
101-
_concurrencyDetector?.EnterCriticalSection();
101+
using var _ = _concurrencyDetector?.EnterCriticalSection();
102102

103-
try
104-
{
105-
return MoveNextHelper();
106-
}
107-
finally
108-
{
109-
_concurrencyDetector?.ExitCriticalSection();
110-
}
103+
return MoveNextHelper();
111104
}
112105
catch (Exception exception)
113106
{
@@ -128,18 +121,11 @@ public ValueTask<bool> MoveNextAsync()
128121
{
129122
try
130123
{
131-
_concurrencyDetector?.EnterCriticalSection();
124+
using var _ = _concurrencyDetector?.EnterCriticalSection();
132125

133-
try
134-
{
135-
_cancellationToken.ThrowIfCancellationRequested();
126+
_cancellationToken.ThrowIfCancellationRequested();
136127

137-
return new ValueTask<bool>(MoveNextHelper());
138-
}
139-
finally
140-
{
141-
_concurrencyDetector?.ExitCriticalSection();
142-
}
128+
return new ValueTask<bool>(MoveNextHelper());
143129
}
144130
catch (Exception exception)
145131
{
@@ -162,7 +148,13 @@ private bool MoveNextHelper()
162148

163149
if (_enumerator == null)
164150
{
151+
#if EF9
152+
#pragma warning disable EF9101
153+
EntityFrameworkMetricsData.ReportQueryExecuting();
154+
#pragma warning restore EF9101
155+
#else
165156
EntityFrameworkEventSource.Log.QueryExecuting();
157+
#endif
166158

167159
try
168160
{

Diff for: tests/MongoDB.EntityFrameworkCore.FunctionalTests/Design/CompiledModelTests.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,11 @@ private static void WriteScaffoldedFile(ScaffoldedFile file, [CallerFilePath] st
205205
var callerDirectory = Path.GetDirectoryName(callerFilePath);
206206
Assert.NotNull(callerDirectory);
207207

208-
var generatedCodePath = Path.Combine(callerDirectory, "Generated");
208+
#if EF9
209+
var generatedCodePath = Path.Combine(callerDirectory, "Generated\\EF9");
210+
#else
211+
var generatedCodePath = Path.Combine(callerDirectory, "Generated\\EF8");
212+
#endif
209213
Directory.CreateDirectory(generatedCodePath);
210214

211215
var fileName = Path.Combine(generatedCodePath, file.Path);

Diff for: tests/MongoDB.EntityFrameworkCore.FunctionalTests/Design/Generated/SimpleContextModelBuilder.cs renamed to tests/MongoDB.EntityFrameworkCore.FunctionalTests/Design/Generated/EF8/SimpleContextModelBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ partial void Initialize()
2020
EveryTypeEntityType.CreateAnnotations(everyType);
2121
OwnedEntityEntityType.CreateAnnotations(ownedEntity);
2222

23-
AddAnnotation("ProductVersion", "8.0.11");
23+
AddAnnotation("ProductVersion", "8.0.12");
2424
}
2525
}
2626
}

0 commit comments

Comments
 (0)