diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index f07d3d71..1e694832 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -692,11 +692,17 @@ jobs:
- Preconditions
- Changes
if: (needs.Preconditions.outputs.lastCommitIsAutoCommit != 'true' || needs.Preconditions.outputs.lastCommitCreatedBeforeSeconds > 300) && needs.Changes.outputs.libred == 'true'
+ # The 365 leg is new: it does not gate the build until it has proven itself stable.
+ continue-on-error: ${{ matrix.aceVersion == '365' }}
strategy:
fail-fast: false
matrix:
+ # 2016 is the out-of-support redistributable; 365 is the current Microsoft 365 Access Runtime, the engine
+ # the cross-checks are measured on. They differ where a test guards itself (BIGINT/DATETIME2, a
+ # backtick-quoted CHECK, a stored query's LvExtra), so those cases only run on the 365 leg.
aceVersion:
- 2016
+ - 365
runs-on: windows-latest
steps:
- name: Checkout
@@ -711,9 +717,38 @@ jobs:
- name: Install Access Database Engine
shell: pwsh
run: |
- $setupFileName = 'AccessDatabaseEngine_${{ matrix.aceVersion }}_x64.exe'
- Invoke-WebRequest "https://cirrusredorg.github.io/EntityFrameworkCore.Jet/$setupFileName" -OutFile $setupFileName
- & ".\$setupFileName" /passive /quiet /norestart REBOOT=ReallySuppress | Out-Default
+ if ('${{ matrix.aceVersion }}' -eq '365')
+ {
+ # The runtime is click-to-run: the Office Deployment Tool downloads it from Microsoft's CDN, so
+ # the tool is fetched from there too rather than hosted.
+ Invoke-WebRequest 'https://officecdn.microsoft.com/pr/wsus/setup.exe' -OutFile setup.exe
+ Set-Content AccessRuntime.xml @'
+
+
+
+
+
+
+
+
+
+ '@
+ $setup = Start-Process .\setup.exe -ArgumentList '/configure', 'AccessRuntime.xml' -Wait -PassThru
+ if ($setup.ExitCode -ne 0) { throw "The Office Deployment Tool exited with $($setup.ExitCode)." }
+ # Since the December 2025 Office builds, ACE refuses every query that reaches another file ("Operation
+ # is not supported for this type of object") unless AllowQueryRemoteTables is 1. The IN externaldatabase
+ # cross-checks were measured with it set, as on the developer machine. -Force on an existing registry
+ # key would wipe its values, so the key is only created when missing.
+ $engines = 'HKLM:\SOFTWARE\Microsoft\Office\16.0\Access Connectivity Engine\Engines'
+ if (-not (Test-Path $engines)) { New-Item $engines -Force | Out-Null }
+ New-ItemProperty $engines -Name AllowQueryRemoteTables -PropertyType DWord -Value 1 -Force | Out-Null
+ }
+ else
+ {
+ $setupFileName = 'AccessDatabaseEngine_${{ matrix.aceVersion }}_x64.exe'
+ Invoke-WebRequest "https://cirrusredorg.github.io/EntityFrameworkCore.Jet/$setupFileName" -OutFile $setupFileName
+ & ".\$setupFileName" /passive /quiet /norestart REBOOT=ReallySuppress | Out-Default
+ }
- name: 'ACE Information'
shell: pwsh
run: |
diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml
index 7ecc936b..64a837c4 100644
--- a/.github/workflows/push.yml
+++ b/.github/workflows/push.yml
@@ -700,11 +700,17 @@ jobs:
- Preconditions
- Changes
if: (needs.Preconditions.outputs.lastCommitIsAutoCommit != 'true' || needs.Preconditions.outputs.lastCommitCreatedBeforeSeconds > 300) && needs.Changes.outputs.libred == 'true'
+ # The 365 leg is new: it does not gate the build until it has proven itself stable.
+ continue-on-error: ${{ matrix.aceVersion == '365' }}
strategy:
fail-fast: false
matrix:
+ # 2016 is the out-of-support redistributable; 365 is the current Microsoft 365 Access Runtime, the engine
+ # the cross-checks are measured on. They differ where a test guards itself (BIGINT/DATETIME2, a
+ # backtick-quoted CHECK, a stored query's LvExtra), so those cases only run on the 365 leg.
aceVersion:
- 2016
+ - 365
runs-on: windows-latest
steps:
- name: Checkout
@@ -719,9 +725,38 @@ jobs:
- name: Install Access Database Engine
shell: pwsh
run: |
- $setupFileName = 'AccessDatabaseEngine_${{ matrix.aceVersion }}_x64.exe'
- Invoke-WebRequest "https://cirrusredorg.github.io/EntityFrameworkCore.Jet/$setupFileName" -OutFile $setupFileName
- & ".\$setupFileName" /passive /quiet /norestart REBOOT=ReallySuppress | Out-Default
+ if ('${{ matrix.aceVersion }}' -eq '365')
+ {
+ # The runtime is click-to-run: the Office Deployment Tool downloads it from Microsoft's CDN, so
+ # the tool is fetched from there too rather than hosted.
+ Invoke-WebRequest 'https://officecdn.microsoft.com/pr/wsus/setup.exe' -OutFile setup.exe
+ Set-Content AccessRuntime.xml @'
+
+
+
+
+
+
+
+
+
+ '@
+ $setup = Start-Process .\setup.exe -ArgumentList '/configure', 'AccessRuntime.xml' -Wait -PassThru
+ if ($setup.ExitCode -ne 0) { throw "The Office Deployment Tool exited with $($setup.ExitCode)." }
+ # Since the December 2025 Office builds, ACE refuses every query that reaches another file ("Operation
+ # is not supported for this type of object") unless AllowQueryRemoteTables is 1. The IN externaldatabase
+ # cross-checks were measured with it set, as on the developer machine. -Force on an existing registry
+ # key would wipe its values, so the key is only created when missing.
+ $engines = 'HKLM:\SOFTWARE\Microsoft\Office\16.0\Access Connectivity Engine\Engines'
+ if (-not (Test-Path $engines)) { New-Item $engines -Force | Out-Null }
+ New-ItemProperty $engines -Name AllowQueryRemoteTables -PropertyType DWord -Value 1 -Force | Out-Null
+ }
+ else
+ {
+ $setupFileName = 'AccessDatabaseEngine_${{ matrix.aceVersion }}_x64.exe'
+ Invoke-WebRequest "https://cirrusredorg.github.io/EntityFrameworkCore.Jet/$setupFileName" -OutFile $setupFileName
+ & ".\$setupFileName" /passive /quiet /norestart REBOOT=ReallySuppress | Out-Default
+ }
- name: 'ACE Information'
shell: pwsh
run: |
diff --git a/AGENTS.md b/AGENTS.md
index 8f4b5e64..f45d7bf5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -7,7 +7,7 @@ It is kept in sync with `CLAUDE.md`; if you change guidance in one, check whethe
EntityFrameworkCore.Jet is an EF Core provider for Microsoft Jet/ACE databases (Microsoft Access `.mdb`/`.accdb` files). The **Jet** provider runs **Windows only** and bridges EF Core to the Access database engine via either ODBC or OLE DB. Alongside it, **LibRed** (also in this repo, on `master`) is a from-scratch managed engine that reads/writes the file format directly and is **cross-platform** — see the LibRed section below.
-Current version: `11.0.0-alpha.5` (`Version.props`) targeting EF Core 11 and `net11.0`; `global.json` pins the 11.0.100 RC2 SDK with `rollForward: latestFeature`. The test projects use **xunit v3**, except `EFCore.Jet.Data.Tests` and `EFCore.Jet.IntegrationTests`, which use MSTest.
+Current version: `11.0.0-beta.1` (`Version.props`) targeting EF Core 11 and `net11.0`; `global.json` pins the 11.0.100 SDK with `rollForward: latestFeature`. The test projects use **xunit v3**, except `EFCore.Jet.Data.Tests` and `EFCore.Jet.IntegrationTests`, which use MSTest.
`LibRed.Core`, `LibRed.Sql`, `LibRed.Engine` and `LibRed.Ado` are the exception: they multi-target
`$(LibRedTargetFrameworks)` = `net10.0;net11.0`, since none of them depends on an EF Core package. `LibRed.EFCore`
@@ -165,7 +165,8 @@ test/
LibRed.EFCore.Tests/ LibRed EF Core provider: query round-trip,
database-first scaffolding [no driver; CI's Windows ACE job]
LibRed.Shared/ Helpers compiled into the Core/Engine test pairs and LibRed.Ado.Tests
- (TemporaryDatabase, …; AceTestDatabase into the AccessTests only)
+ (TemporaryDatabase, …; AceTestDatabase into the AccessTests only;
+ MalformedFile into LibRed.Core.Tests and LibRed.Core.Fuzz)
EFCore.LibRed.FunctionalTests/ EF Core specification suite over LibRed, compatible
SQL mode (Jet-dialect SQL) [cross-platform]
EFCore.LibRed.Extended.FunctionalTests/
@@ -176,6 +177,9 @@ test/
split, storage, writes, DDL, catalog, and an opt-in ACE
head-to-head. `-- --validate` checks the SQL corpus.
See its README.md [cross-platform]
+ LibRed.Core.Fuzz/ SharpFuzz + libFuzzer harness over LibRed.Core: damaged databases
+ and blob decoders, held to the sweep's leak contract. Not in CI;
+ needs third-party tools. See its README.md [cross-platform]
Shared/ For the EF functional suites: ModuleInitializer.cs (locks culture to
en-US) and TestUtilities/ (test orderers, crash detection, conditions)
@@ -405,8 +409,10 @@ flags — `jet` and `libred` — and skips the jobs that don't apply:
partway through the largest shard.
- **LibRed** — `LibRed.Engine.Tests` and `LibRed.Core.Tests` on Linux/Windows/macOS + ubuntu-arm/windows-arm,
no ACE anywhere.
-- **LibRedAccess** — the ACE cross-check suites on `windows-latest` with ACE 2016, plus `LibRed.Ado.Tests` and
- `LibRed.EFCore.Tests`, which need no driver but run only there for now.
+- **LibRedAccess** — the ACE cross-check suites on `windows-latest`, plus `LibRed.Ado.Tests` and
+ `LibRed.EFCore.Tests`, which need no driver but run only there for now. Two legs: the 2016 redistributable, and
+ the Microsoft 365 Access Runtime installed through the Office Deployment Tool, where the version-guarded cases
+ (BIGINT/DATETIME2, backtick CHECKs) actually run. The 365 leg is `continue-on-error` until it proves stable.
- **LibRedFunctional** — both `EFCore.LibRed.FunctionalTests` (compatible mode) and
`EFCore.LibRed.Extended.FunctionalTests` (extended mode) on the five-platform matrix, `continue-on-error`.
- **NuGet** — packs for `master`, `*-servicing`, `*-wip` and release tags, attaching the packages to the run
diff --git a/CLAUDE.md b/CLAUDE.md
index 57b85d15..2b937041 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
EntityFrameworkCore.Jet is an EF Core provider for Microsoft Jet/ACE databases (Microsoft Access `.mdb`/`.accdb` files). The **Jet** provider runs **Windows only** and bridges EF Core to the Access database engine via either ODBC or OLE DB. Alongside it, **LibRed** (also in this repo, on `master`) is a from-scratch managed engine that reads/writes the file format directly and is **cross-platform** — see the LibRed section below.
-Current version: `11.0.0-alpha.5` (`Version.props`) targeting EF Core 11 and `net11.0`; `global.json` pins the 11.0.100 RC2 SDK with `rollForward: latestFeature`. The test projects use **xunit v3**, except `EFCore.Jet.Data.Tests` and `EFCore.Jet.IntegrationTests`, which use MSTest.
+Current version: `11.0.0-beta.1` (`Version.props`) targeting EF Core 11 and `net11.0`; `global.json` pins the 11.0.100 SDK with `rollForward: latestFeature`. The test projects use **xunit v3**, except `EFCore.Jet.Data.Tests` and `EFCore.Jet.IntegrationTests`, which use MSTest.
**One exception to `net11.0`:** `LibRed.Core`, `LibRed.Sql`, `LibRed.Engine` and `LibRed.Ado` multi-target
`$(LibRedTargetFrameworks)` = `net10.0;net11.0`, because none of them depends on an EF Core package. `LibRed.EFCore`
@@ -169,7 +169,8 @@ test/
LibRed.EFCore.Tests/ LibRed EF Core provider: query round-trip,
database-first scaffolding [no driver; CI's Windows ACE job]
LibRed.Shared/ Helpers compiled into the Core/Engine test pairs and LibRed.Ado.Tests
- (TemporaryDatabase, …; AceTestDatabase into the AccessTests only)
+ (TemporaryDatabase, …; AceTestDatabase into the AccessTests only;
+ MalformedFile into LibRed.Core.Tests and LibRed.Core.Fuzz)
EFCore.LibRed.FunctionalTests/ EF Core specification suite over LibRed, compatible
SQL mode (Jet-dialect SQL) [cross-platform]
EFCore.LibRed.Extended.FunctionalTests/
@@ -180,6 +181,9 @@ test/
split, storage, writes, DDL, catalog, and an opt-in ACE
head-to-head. `-- --validate` checks the SQL corpus.
See its README.md [cross-platform]
+ LibRed.Core.Fuzz/ SharpFuzz + libFuzzer harness over LibRed.Core: damaged databases
+ and blob decoders, held to the sweep's leak contract. Not in CI;
+ needs third-party tools. See its README.md [cross-platform]
Shared/ For the EF functional suites: ModuleInitializer.cs (locks culture to
en-US) and TestUtilities/ (test orderers, crash detection, conditions)
@@ -415,8 +419,10 @@ flags — `jet` and `libred` — and skips the jobs that don't apply:
partway through the largest shard.
- **LibRed** — `LibRed.Engine.Tests` and `LibRed.Core.Tests` on Linux/Windows/macOS + ubuntu-arm/windows-arm,
no ACE anywhere.
-- **LibRedAccess** — the ACE cross-check suites on `windows-latest` with ACE 2016, plus `LibRed.Ado.Tests` and
- `LibRed.EFCore.Tests`, which need no driver but run only there for now.
+- **LibRedAccess** — the ACE cross-check suites on `windows-latest`, plus `LibRed.Ado.Tests` and
+ `LibRed.EFCore.Tests`, which need no driver but run only there for now. Two legs: the 2016 redistributable, and
+ the Microsoft 365 Access Runtime installed through the Office Deployment Tool, where the version-guarded cases
+ (BIGINT/DATETIME2, backtick CHECKs) actually run. The 365 leg is `continue-on-error` until it proves stable.
- **LibRedFunctional** — both `EFCore.LibRed.FunctionalTests` (compatible mode) and
`EFCore.LibRed.Extended.FunctionalTests` (extended mode) on the five-platform matrix, `continue-on-error`.
- **NuGet** — packs for `master`, `*-servicing`, `*-wip` and release tags, attaching the packages to the run
diff --git a/Directory.Packages.props b/Directory.Packages.props
index bf2ca305..fbcb09b5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,8 +1,8 @@
true
- [11.0.0-rc.2.26504.105]
- [11.0.0-rc.2.26504.105]
+ [11.0.0,11.0.999]
+ [11.0.0,11.0.999]
@@ -25,11 +25,12 @@
-
+
+
-
-
-
+
+
+
diff --git a/EFCore.Jet.sln b/EFCore.Jet.sln
index 5157a78a..9b1e42f5 100644
--- a/EFCore.Jet.sln
+++ b/EFCore.Jet.sln
@@ -89,6 +89,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.LibRed.Extended.Func
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibRed.Core.AccessTests", "test\LibRed.Core.AccessTests\LibRed.Core.AccessTests.csproj", "{681BEAF7-FB98-4E12-81F1-055DF766AFC4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibRed.Core.Fuzz", "test\LibRed.Core.Fuzz\LibRed.Core.Fuzz.csproj", "{62DA6569-9508-471D-A4ED-72E8BF2C70B0}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -387,6 +389,18 @@ Global
{681BEAF7-FB98-4E12-81F1-055DF766AFC4}.Release|x64.Build.0 = Release|x64
{681BEAF7-FB98-4E12-81F1-055DF766AFC4}.Release|x86.ActiveCfg = Release|x86
{681BEAF7-FB98-4E12-81F1-055DF766AFC4}.Release|x86.Build.0 = Release|x86
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|x64.ActiveCfg = Debug|x64
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|x64.Build.0 = Debug|x64
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|x86.ActiveCfg = Debug|x86
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Debug|x86.Build.0 = Debug|x86
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|x64.ActiveCfg = Release|x64
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|x64.Build.0 = Release|x64
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|x86.ActiveCfg = Release|x86
+ {62DA6569-9508-471D-A4ED-72E8BF2C70B0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Version.props b/Version.props
index 57d74c37..7b97835a 100644
--- a/Version.props
+++ b/Version.props
@@ -16,8 +16,8 @@
correctly.
-->
11.0.0
- alpha
- 5
+ beta
+ 1
+
+
diff --git a/src/LibRed/LibRed.Core/Pages/DataPage.cs b/src/LibRed/LibRed.Core/Pages/DataPage.cs
index 9ae17236..5cc8945c 100644
--- a/src/LibRed/LibRed.Core/Pages/DataPage.cs
+++ b/src/LibRed/LibRed.Core/Pages/DataPage.cs
@@ -288,10 +288,14 @@ private static void ValidateSlot(PageBuffer buffer, int index, int offset, int p
/// masked out of and so can exceed the page; rows are packed from the page end
/// backward, so they must also never increase. RowInserter's in-place repackers re-derived this
/// arithmetic without the checks, which on a corrupt directory produced an out-of-range exception from a
- /// half-repacked page rather than a diagnosis.
+ /// half-repacked page rather than a diagnosis. The previous boundary is checked too: a directory walk has
+ /// already validated it, but reads it straight from the neighbouring slot.
internal static void ValidateSlot(
int pageNumber, int bufferLength, int index, int offset, int previousEnd, int directoryEnd)
{
+ if (previousEnd > bufferLength)
+ throw new InvalidDataException(
+ $"Data page {pageNumber} row slot {index - 1} has offset {previousEnd}, past the page end {bufferLength}.");
if (offset < directoryEnd || offset > bufferLength)
throw new InvalidDataException(
$"Data page {pageNumber} row slot {index} has offset {offset}, outside the row heap " +
diff --git a/src/LibRed/LibRed.Core/Storage/BitmapBits.cs b/src/LibRed/LibRed.Core/Storage/BitmapBits.cs
index f37ce293..ad0664cd 100644
--- a/src/LibRed/LibRed.Core/Storage/BitmapBits.cs
+++ b/src/LibRed/LibRed.Core/Storage/BitmapBits.cs
@@ -70,6 +70,10 @@ public static void AppendPages(
for (int bit = NextSetBit(bitmap, 0); bit >= 0; bit = NextSetBit(bitmap, bit + 1))
{
long page = (long)basePage + bit;
+ // Keeping every bit keeps pages past the file's end, never a page no file can have: a negative one
+ // would be taken for a bit index below the bitmap's first byte.
+ if (page is < 0 or > int.MaxValue)
+ throw new InvalidDataException($"{what} names page {page}, which no file can hold.");
if (rejectBeyond is { } pageCount && (page <= 1 || page >= pageCount))
throw new InvalidDataException(
$"{what} names page {page}, outside the file's 2..{pageCount - 1} range.");
diff --git a/src/LibRed/LibRed.Core/Storage/CalculatedValue.cs b/src/LibRed/LibRed.Core/Storage/CalculatedValue.cs
index 138edd2b..5eff702f 100644
--- a/src/LibRed/LibRed.Core/Storage/CalculatedValue.cs
+++ b/src/LibRed/LibRed.Core/Storage/CalculatedValue.cs
@@ -150,6 +150,9 @@ private static byte[] EncodePayload(ColumnDef column, JetDataType type, object v
$"Calculated column '{column.Name}' contains an invalid expression: its descriptor lacks the flag that "
+ "lets the expression be evaluated.");
+ // The width first: a slot too short to be an envelope is damage, and its first four bytes are no status.
+ ReadOnlySpan payload = Payload(envelope, column);
+
// A failed expression is cached as its VBA error number with no payload, so it is NOT a Null even
// though it has a Null's empty payload -- and reading it as one is a silent wrong answer, on a value
// neither engine re-derives. ACE will not hand back such a row at all.
@@ -158,7 +161,6 @@ private static byte[] EncodePayload(ColumnDef column, JetDataType type, object v
$"Calculated column '{column.Name}' holds a cached error, not a value: "
+ $"{VbaErrorText(error)}. Its expression is '{column.CalculatedExpression ?? "(unknown)"}'.");
- ReadOnlySpan payload = Payload(envelope, column);
JetDataType type = StoredType(column, payload.Length);
// A zero-length payload is a Null result -- EXCEPT for text, where it is the empty string. The two
@@ -172,10 +174,9 @@ private static byte[] EncodePayload(ColumnDef column, JetDataType type, object v
}
/// The envelope's leading status: 0 when the expression produced a value, otherwise the VBA
- /// runtime error number it raised. A short envelope reads as 0 — a truncated slot is the width check's
- /// business, not this one's.
+ /// runtime error number it raised. Read only after has checked the width.
private static uint Status(ReadOnlySpan envelope) =>
- envelope.Length >= StatusSize ? BinaryPrimitives.ReadUInt32LittleEndian(envelope[..StatusSize]) : 0;
+ BinaryPrimitives.ReadUInt32LittleEndian(envelope[..StatusSize]);
/// Names the VBA errors a calculated expression can actually raise, so the message says what
/// went wrong rather than quoting a number. Measured: CDbl(Null) caches 94 and CDbl('hello')
diff --git a/src/LibRed/LibRed.Core/Storage/IndexTree.cs b/src/LibRed/LibRed.Core/Storage/IndexTree.cs
index 96ffb12a..bc34a7c9 100644
--- a/src/LibRed/LibRed.Core/Storage/IndexTree.cs
+++ b/src/LibRed/LibRed.Core/Storage/IndexTree.cs
@@ -177,8 +177,10 @@ public void RemoveEntry(IndexDef index, object?[] values, RowId rowId)
int idx = LowerBound(entries, key);
while (idx < entries.Count && CompareBytes(entries[idx].Key, key) == 0 && entries[idx].Trailer != pointer) idx++;
+ // The key is built from the row's own stored values, so a missing entry is an index that disagrees with its
+ // table: damage, which ACE refuses too ("The search key was not found in any record.", measured).
if (idx == entries.Count || entries[idx].Trailer != pointer || CompareBytes(entries[idx].Key, key) != 0)
- throw new InvalidOperationException(
+ throw new InvalidDataException(
$"Index '{index.Name}': entry for row {rowId.Page}:{rowId.Row} was not found on leaf {leafPage}.");
entries.RemoveAt(idx);
diff --git a/src/LibRed/LibRed.Core/Storage/JetLocaleTailoring.cs b/src/LibRed/LibRed.Core/Storage/JetLocaleTailoring.cs
index 820a5318..b11998aa 100644
--- a/src/LibRed/LibRed.Core/Storage/JetLocaleTailoring.cs
+++ b/src/LibRed/LibRed.Core/Storage/JetLocaleTailoring.cs
@@ -155,8 +155,9 @@ private bool TryLongest(ReadOnlySpan text, int start, out TailoredWeight w
{
for (int length = Math.Min(MaxLength, text.Length - start); length >= 1; length--)
{
- // A lowercase letter followed by an uppercase one breaks a contraction, which then falls to a shorter
- // match: "cS" is c and S, "dzS" is dz and S, "dZs" is d and zs (verified vs ACE in every digraph order).
+ // A contraction matches only in lowercase, uppercase or title case; any other mix falls to a shorter
+ // match: "cS" is c and S, "dzS" is dz and S, "dZs" is d and zs, "DZs" is DZ and s (verified vs ACE in
+ // every case mix of every contraction).
if (BreaksCase(text.Slice(start, length)))
continue;
if (TryGet(text.Slice(start, length), out weight))
@@ -172,7 +173,8 @@ private bool TryLongest(ReadOnlySpan text, int start, out TailoredWeight w
static bool BreaksCase(ReadOnlySpan candidate)
{
for (int i = 0; i + 1 < candidate.Length; i++)
- if (char.IsLower(candidate[i]) && char.IsUpper(candidate[i + 1]))
+ if ((char.IsLower(candidate[i]) && char.IsUpper(candidate[i + 1])) ||
+ (i > 0 && char.IsUpper(candidate[i]) && char.IsLower(candidate[i + 1])))
return true;
return false;
}
diff --git a/src/LibRed/LibRed.Core/Storage/PageAllocator.cs b/src/LibRed/LibRed.Core/Storage/PageAllocator.cs
index 8a353989..8dc6ed2b 100644
--- a/src/LibRed/LibRed.Core/Storage/PageAllocator.cs
+++ b/src/LibRed/LibRed.Core/Storage/PageAllocator.cs
@@ -446,41 +446,49 @@ public void ReturnReleasedPages()
{
SortedSet pages = [.. _channel.PagesReleasedAtClose];
if (pages.Count == 0 && !_channel.HasPublishedWrites && _reservationBits == 0 && _groups.Count == 0) return;
- (_, MapRecord released) = ReadGlobalMaps();
- // Every bit kept, none bounded by the file: a released page past its end was never materialized, and is
- // skipped below.
- pages.UnionWith(UsageMap.PagesInRecord(_channel, released.Record, rejectBeyond: null, "The global released-pages map"));
- if (pages.Count == 0 && _reservationBits == 0 && _groups.Count == 0) return;
- bool ownTransaction = !_channel.InTransaction;
- if (ownTransaction) _channel.BeginTransaction();
- try
- {
- // Sized before the merge: a conversion allocates its bitmap pages from the free map as it stands,
- // without the pages being released.
- if (pages.Count != 0) SizeReleasedMap(pages);
- ReturnGroups();
-
- // A released page past the end of the file was never materialized; the free map already records
- // every page past the end as free.
- foreach (int page in pages)
- if (page < _channel.PageCount) Free(page);
- for (int bit = 0; bit < 32; bit++)
- if ((_reservationBits & (1u << bit)) != 0) Free(_reservationStart + bit);
- _reservationBits = 0;
- _owners.Clear();
- _bitmapSlot = 0;
-
- (_, released) = ReadGlobalMaps();
- ClearReleasedMap(released);
- _channel.ClearPagesReleasedAtClose();
- if (ownTransaction) _channel.CommitTransaction(flush: false);
- }
- catch
+ // In the file's exclusive scope, as a writing statement runs: the global maps are read, rewritten and
+ // committed with no other connection committing between. Outside it, a statement on another connection
+ // could commit page 1 after this transaction first wrote it, and the commit would fail as a write conflict.
+ _channel.WriteExclusive(() =>
{
- if (ownTransaction) _channel.RollbackTransaction();
- throw;
- }
+ (_, MapRecord released) = ReadGlobalMaps();
+ // Every bit kept, none bounded by the file: a released page past its end was never materialized, and is
+ // skipped below.
+ pages.UnionWith(UsageMap.PagesInRecord(_channel, released.Record, rejectBeyond: null, "The global released-pages map"));
+ if (pages.Count == 0 && _reservationBits == 0 && _groups.Count == 0) return false;
+
+ bool ownTransaction = !_channel.InTransaction;
+ if (ownTransaction) _channel.BeginTransaction();
+ try
+ {
+ // Sized before the merge: a conversion allocates its bitmap pages from the free map as it stands,
+ // without the pages being released.
+ if (pages.Count != 0) SizeReleasedMap(pages);
+ ReturnGroups();
+
+ // A released page past the end of the file was never materialized; the free map already records
+ // every page past the end as free.
+ foreach (int page in pages)
+ if (page < _channel.PageCount) Free(page);
+ for (int bit = 0; bit < 32; bit++)
+ if ((_reservationBits & (1u << bit)) != 0) Free(_reservationStart + bit);
+ _reservationBits = 0;
+ _owners.Clear();
+ _bitmapSlot = 0;
+
+ (_, released) = ReadGlobalMaps();
+ ClearReleasedMap(released);
+ _channel.ClearPagesReleasedAtClose();
+ if (ownTransaction) _channel.CommitTransaction(flush: false);
+ }
+ catch
+ {
+ if (ownTransaction) _channel.RollbackTransaction();
+ throw;
+ }
+ return true;
+ });
}
///
@@ -512,7 +520,9 @@ private void SizeReleasedMap(SortedSet pages)
int start = UsageMap.StartPage(released.Record, format);
int lowest = pages.Min, highest = pages.Max;
int Covering(int from) => headerSize + UsageMap.InlineBitmapBytes(format, highest - from + 1);
- if (lowest >= start && highest < start + (released.Slot.Length - headerSize) * 8) return;
+ // A map starting below page 0 is left as it was, and the pages are freed all the same: ACE's close does
+ // (measured, start -2,147,483,648).
+ if (start < 0 || lowest >= start && highest < start + (released.Slot.Length - headerSize) * 8) return;
var holder = new DataPage();
holder.Read(new PageBuffer(released.Page, released.PageNumber), format);
@@ -868,6 +878,11 @@ private static void ValidateReusablePage(int page, string source, MapRecord free
/// against two ACE handles.
private void EnsurePhysicalAllocation(int page)
{
+ // A page past the largest file is in no database: ACE refuses to allocate it and leaves the file as it was
+ // (measured), where growing towards it would buffer pages up to the 2 GiB limit before WritePage refused one.
+ if (page > _channel.PageCount && page >= _channel.MaxPageCount)
+ throw new InvalidDataException(
+ $"The global free map selected page {page}, past the largest file of {_channel.MaxPageCount} pages.");
while (_channel.PageCount < page) Append();
if (page < _channel.PageCount) return;
int allocated = Append();
diff --git a/src/LibRed/LibRed.Core/Storage/RowCodec.cs b/src/LibRed/LibRed.Core/Storage/RowCodec.cs
index 3215811e..9044b87a 100644
--- a/src/LibRed/LibRed.Core/Storage/RowCodec.cs
+++ b/src/LibRed/LibRed.Core/Storage/RowCodec.cs
@@ -76,9 +76,9 @@ public sealed class RowCodec(IReadOnlyList columns, JetFormatBase for
/// The zero bytes to leave between the variable data and its offset table (spec §5), from
/// the variable chunks this row is written with, by variable index; null for none.
/// The buffer an UPDATE builds its rows in, one per statement and table, page-sized and
- /// zeroed at the start: is copied in, the row is built over it, and the row is left in
- /// it — so a byte the row does not write and its old record did not reach holds the last updated record that
- /// did (verified vs ACE, UpdateRowBufferProbeTest). Null for none.
+ /// zeroed at the start: is copied in and the row is built over it, and the caller leaves
+ /// the row in it once the row is known to fit — so a byte the row does not write and its old record did not reach
+ /// holds the last updated record that did (verified vs ACE, UpdateRowBufferProbeTest). Null for none.
internal byte[] Encode(object?[] values, IReadOnlyDictionary? preservedCalculated,
object?[]? logicalValues = null, Layout prior = default, Func, int>? slackOf = null,
byte[]? buffer = null)
@@ -112,10 +112,8 @@ internal byte[] Encode(object?[] values, IReadOnlyDictionary? prese
varChunks[column.VariableIndex] = v is null ? [] : JetTypeCodec.Encode(column, v, _format);
}
- byte[] row = AssembleRow(_format, _maxColumnId, fixedRegion, varChunks, _columns, values, prior.NullBitmap,
+ return AssembleRow(_format, _maxColumnId, fixedRegion, varChunks, _columns, values, prior.NullBitmap,
slackOf?.Invoke(varChunks) ?? 0, buffer);
- if (buffer is not null) row.CopyTo(buffer, 0);
- return row;
}
/// The fixed region of a row being written over :
diff --git a/src/LibRed/LibRed.Core/Storage/RowInserter.cs b/src/LibRed/LibRed.Core/Storage/RowInserter.cs
index aa8ff8db..3963a66d 100644
--- a/src/LibRed/LibRed.Core/Storage/RowInserter.cs
+++ b/src/LibRed/LibRed.Core/Storage/RowInserter.cs
@@ -204,6 +204,10 @@ private void UpdateCore(RowId id, object?[] values, IReadOnlySet changedCol
// unreadable row an INSERT was stopped from producing.
EnsureRecordFits(format, record);
+ // The row is left in the statement's buffer for the next one built over it — only once it is known to fit,
+ // since one grown past the page does not fit the buffer either.
+ if (buffer is not null) record.CopyTo(buffer, 0);
+
if (DataPage.ReadSlot(srcPage.Span, format, id.Row).Flags.HasFlag(RowSlotFlags.Overflow))
{
// This slot is a forward record pointer to the real (relocated) row; rewrite it on its target page
@@ -1221,9 +1225,17 @@ private TableDefinition ReadDefinition()
///
private bool[]? AssignAutoNumbers(JetFormatBase format, object?[] values, ReadOnlySpan tdef)
{
+ // The counter is four bytes. A fixed column of another width carrying the AutoNumber flag — a damaged
+ // descriptor — cannot hold it: ACE draws the id all the same and then refuses the row, explicit value or not
+ // (measured on Integer, Currency and Date/Time columns; Single and Long, four bytes, take theirs). A random
+ // AutoNumber draws no id, so it is left as it was.
+ static bool CannotHoldTheCounter(ColumnDef column) =>
+ column.IsFixedLength && column.Type != JetDataType.Boolean && column.Length != sizeof(int)
+ && !column.IsRandomAutoNumber;
+
bool needed = false;
foreach (ColumnDef column in _table.Columns)
- if (column.IsAutoNumber && values[column.Index] is null or DBNull) { needed = true; break; }
+ if (column.IsAutoNumber && (values[column.Index] is null or DBNull || CannotHoldTheCounter(column))) { needed = true; break; }
if (!needed) return null;
int highWater = TableDefinition.ReadLastAutoNumber(tdef, format);
@@ -1237,7 +1249,8 @@ private TableDefinition ReadDefinition()
bool[] generated = new bool[values.Length];
foreach (ColumnDef column in _table.Columns)
- if (column.IsAutoNumber && column.Type != JetDataType.Complex && values[column.Index] is null or DBNull)
+ if (column.IsAutoNumber && column.Type != JetDataType.Complex
+ && (values[column.Index] is null or DBNull || CannotHoldTheCounter(column)))
{
if (column.IsRandomAutoNumber)
// "Random" AutoNumber (DefaultValue = GenUniqueID()): a random Int32, independent of the
@@ -1249,9 +1262,13 @@ private TableDefinition ReadDefinition()
// Seed-Increment, so the first assigned id is the Seed. The addition is deliberately
// unchecked: past int.MaxValue the counter wraps to int.MinValue and keeps going, which
// is exactly what ACE does (no overflow error exists — see AceAutoNumberOverflowProbeTest).
- values[column.Index] = highWater = unchecked(highWater + column.Increment);
- generated[column.Index] = true;
+ highWater = unchecked(highWater + column.Increment);
_channel.KeepThroughRollback(_table.DefinitionPage, format.TdefLastAutoNumberOffset, highWater);
+ if (CannotHoldTheCounter(column))
+ throw new InvalidOperationException(
+ $"The field '{column.Name}' is too small to accept the amount of data you attempted to add.");
+ values[column.Index] = highWater;
+ generated[column.Index] = true;
}
}
return generated;
@@ -1331,7 +1348,17 @@ private void UpdateTdefCounters(JetFormatBase format, byte[] tdef, object?[] val
// a UI-authored Random AutoNumber reads last-value 0). Advancing it would be meaningless (random ids
// don't form a monotone sequence) and diverge from Access's on-disk state.
if (column.IsRandomAutoNumber) continue;
- int assigned = Convert.ToInt32(value, CultureInfo.InvariantCulture);
+ // The counter is a value's first four bytes. On a Text, OLE or Single column that carries the AutoNumber
+ // flag — a damaged descriptor — ACE takes them from the UTF-16 text, zero-padded, from the binary value,
+ // or from the float (measured: "Street" sets 0x14 to 0x00740053, "A" to 65, bytes 01 02 03 04 05 06 to
+ // 0x04030201, 0.25 to 0x3E800000).
+ int assigned = value switch
+ {
+ string text => (text.Length > 0 ? text[0] : 0) | (text.Length > 1 ? text[1] << 16 : 0),
+ float single => BitConverter.SingleToInt32Bits(single),
+ byte[] bytes => bytes.Take(4).Select((b, i) => b << (8 * i)).Aggregate(0, (counter, b) => counter | b),
+ _ => Convert.ToInt32(value, CultureInfo.InvariantCulture),
+ };
int highWater = TableDefinition.ReadLastAutoNumber(tdef, format);
// An id this insert *generated* always becomes the new high-water: it came from 0x14 + increment,
// so it is by construction the next value in the sequence. That includes the wrap past
diff --git a/src/LibRed/LibRed.Core/Storage/Table.cs b/src/LibRed/LibRed.Core/Storage/Table.cs
index 4b6420d4..dc63680d 100644
--- a/src/LibRed/LibRed.Core/Storage/Table.cs
+++ b/src/LibRed/LibRed.Core/Storage/Table.cs
@@ -258,7 +258,11 @@ public void Delete(RowId id)
Write(() =>
{
object?[] values = GetRow(id, StoredColumns) ?? throw new InvalidOperationException($"Row '{id}' does not exist.");
- foreach (ComplexColumn complex in _catalog.LoadComplexColumns(Definition.DefinitionPage))
+ // Only a table with a complex column has values elsewhere to remove, so only it asks MSysComplexColumns:
+ // on a file whose registry is damaged, ACE deletes from any other table as usual (measured).
+ IEnumerable complexColumns = Definition.Columns.Any(c => c.Type == JetDataType.Complex)
+ ? _catalog.LoadComplexColumns(Definition.DefinitionPage) : [];
+ foreach (ComplexColumn complex in complexColumns)
{
if (values[complex.OwnerTable.RequireColumn(complex.ColumnName).Index] is not { } raw) continue;
int recordId = Convert.ToInt32(raw, System.Globalization.CultureInfo.InvariantCulture);
diff --git a/src/LibRed/LibRed.EFCore/Storage/Internal/LibRedRelationalConnection.cs b/src/LibRed/LibRed.EFCore/Storage/Internal/LibRedRelationalConnection.cs
index f6469a52..a653ce1a 100644
--- a/src/LibRed/LibRed.EFCore/Storage/Internal/LibRedRelationalConnection.cs
+++ b/src/LibRed/LibRed.EFCore/Storage/Internal/LibRedRelationalConnection.cs
@@ -1,3 +1,7 @@
+using System.Data;
+using EntityFrameworkCore.Jet.Infrastructure;
+using EntityFrameworkCore.LibRed.Infrastructure;
+using EntityFrameworkCore.LibRed.Infrastructure.Internal;
using LibRed.Data;
namespace EntityFrameworkCore.LibRed.Storage.Internal;
@@ -11,5 +15,16 @@ public class LibRedRelationalConnection(RelationalConnectionDependencies depende
: RelationalConnection(dependencies), ILibRedRelationalConnection
{
protected override DbConnection CreateDbConnection()
- => new LibRedConnection { ConnectionString = ConnectionString };
+ {
+ var connection = new LibRedConnection { ConnectionString = ConnectionString };
+ if (Dependencies.ContextOptions.FindExtension()?.SqlMode == LibRedSqlMode.Compatible)
+ {
+ connection.StateChange += (_, e) =>
+ {
+ if (e.CurrentState == ConnectionState.Open)
+ JetDualTable.DetectedName = connection.HasDualTable ? LibRedConnection.DualTableName : "";
+ };
+ }
+ return connection;
+ }
}
\ No newline at end of file
diff --git a/src/LibRed/LibRed.Engine/Execution/StatementExecutor.cs b/src/LibRed/LibRed.Engine/Execution/StatementExecutor.cs
index f38e65ea..6b8ed92c 100644
--- a/src/LibRed/LibRed.Engine/Execution/StatementExecutor.cs
+++ b/src/LibRed/LibRed.Engine/Execution/StatementExecutor.cs
@@ -845,13 +845,16 @@ private int RenameColumn(string table, string field, string newName)
}
///
- /// RENAME INDEX — renames an index; the name lives in the TDEF's index block. If the index backs a foreign
- /// key, check its coupling to the relationship name (szRelationship). Access cannot do this through
- /// SQL or DAO/ADOX, so there is no ACE oracle for the operation itself — verify via the converged
- /// end state (an index created as the new name should match one created then renamed).
+ /// RENAME INDEX — renames an index; the name lives in the TDEF's logical index block. ACE has no SQL for it,
+ /// but DAO renames one through Index.Name, and LibRed matches that (see SchemaEditor.RenameIndex).
///
- private int RenameIndex(string table, string index, string newName) => throw new NotSupportedException(
- $"ALTER TABLE `{table}` RENAME INDEX `{index}` TO `{newName}` is parsed and routed but the TDEF rewrite is not implemented yet.");
+ private int RenameIndex(string table, string index, string newName)
+ {
+ if (!_database.RenameIndex(table, index, newName))
+ throw new InvalidOperationException(
+ $"ALTER TABLE '{table}' RENAME INDEX '{index}' TO '{newName}': the index was not found.");
+ return 0;
+ }
private int DropConstraint(string table, string name)
{
diff --git a/src/LibRed/README.md b/src/LibRed/README.md
index b314b675..fb50018e 100644
--- a/src/LibRed/README.md
+++ b/src/LibRed/README.md
@@ -194,13 +194,14 @@ Treat the number as of its date — an EF Core version bump moves it.
read back onto the column, and applied when an insert omits the column — **and Access honors them too**.
Table-level `CHECK` constraints are persisted to the `LvProp` `CheckConstraints` property (verbatim
expression text) and read back onto `TableDefinition.CheckConstraints` — **and Access enforces them**.
- From files Access wrote, a relationship's 1:1 flag (`grbit` `0x01`) is read and reported as ONE/MANY by
- `INFORMATION_SCHEMA`, and a column's `ValidationRule`/`ValidationText` are read off the same property blob,
+ A relationship's 1:1 flag (`grbit` `0x01`) is read and reported as ONE/MANY by `INFORMATION_SCHEMA`, and
+ written through the Core API (`RelationshipSpec.IsOneToOne`) as DAO's `dbRelationUnique` writes it — SQL has no
+ syntax for it. A column's `ValidationRule`/`ValidationText` are read off the `LvProp` property blob,
reported by `INFORMATION_SCHEMA` and kept through a rewrite.
- **SQL** — ANTLR front end (parser → binder via `ISchemaProvider` → planner → executor). Statements:
`CREATE TABLE`, `CREATE [UNIQUE] INDEX … [WITH {PRIMARY|DISALLOW NULL|IGNORE NULL}]`, `CREATE VIEW`,
`CREATE PROCEDURE`, `ALTER TABLE` (ADD/DROP COLUMN, ADD PK/FK/UNIQUE/CHECK, ALTER COLUMN incl. the
- byte-faithful in-place type change and `SET`/`DROP DEFAULT`, DROP CONSTRAINT, `RENAME TO`/`RENAME COLUMN`),
+ byte-faithful in-place type change and `SET`/`DROP DEFAULT`, DROP CONSTRAINT, `RENAME TO`/`RENAME COLUMN`/`RENAME INDEX`),
`DROP {TABLE|INDEX|VIEW|PROCEDURE}`, `INSERT`
(with AutoNumber) — from `VALUES`, from a multi-row table value constructor, or from a query
(`INSERT INTO … SELECT`, the append query) — `SELECT … INTO` (the make-table query), `UPDATE`, `DELETE`,
@@ -324,8 +325,6 @@ Format-level detail on each on-disk gap lives in `docs/format/`.
- **`ON UPDATE SET NULL`** — pathway threaded but throws; its Jet storage bytes are unverified because the
ACE OLE DB provider rejects the DDL (needs a UI/DAO-created sample to probe).
-- **1:1 relationships** (`dbRelationUnique` = `0x01`) — never written; a 1:1 migration would render as 1:many
- in Access (the unique index still enforces uniqueness).
- **`ValidationRule`/`ValidationText` are not enforced** — UI-authored validation, distinct from a SQL `CHECK`:
a row violating an Access-authored rule is accepted where ACE would refuse it.
- **A column-level `CHECK`** (`Col LONG CHECK (Col > 0)`) is parsed and silently dropped — neither stored nor
@@ -340,7 +339,6 @@ Format-level detail on each on-disk gap lives in `docs/format/`.
- **Stored pass-through queries** — read back as a *named* refusal rather than executing.
- **A crosstab's columns when describing** (`CommandBehavior.SchemaOnly`) — only the row headings and fixed
headings, since the rest come from the data.
-- **`ALTER TABLE … RENAME INDEX`** — parsed and routed, but throws: the TDEF rewrite is not implemented.
- **Function surface** — the evaluator's whitelist isn't proven identical to ACE's JES, and `Format`'s named
date/currency formats are locale-dependent by design (not byte-identical cross-locale).
- **Single-writer concurrency** — LibRed is a **single-writer engine that merely tolerates extra open
diff --git a/src/LibRed/docs/format/page-02a-tdef.md b/src/LibRed/docs/format/page-02a-tdef.md
index d885be4e..a5b30916 100644
--- a/src/LibRed/docs/format/page-02a-tdef.md
+++ b/src/LibRed/docs/format/page-02a-tdef.md
@@ -94,6 +94,22 @@
> it pins `0x14` at `int.MaxValue` forever, so every later insert reissues `int.MinValue` and the table is
> wedged — for ACE too, since the damage is the on-disk `0x14`. LibRed therefore applies its monotone guard
> (the deliberate KB 884185 immunity) **only to caller-supplied explicit ids**; see `RowInserter`.
+>
+> **The counter is the first four bytes of the value (verified vs ACE).** A Text column whose descriptor carries
+> the AutoNumber flag `0x04` (a damaged file) still opens, reads and takes INSERTs and DELETEs; an UPDATE of the
+> column is refused as not updateable. An explicit text value sets `0x14` to the value's first four bytes as UTF-16LE,
+> zero-padded: `'Street'` → `0x00740053`, `'500'` → `0x00300035`, `'A'` → `65`. A generated id goes the other way —
+> with the flag byte `0x06` the id's four bytes are stored as two characters (`0x00740054` → `'Tt'`); with `0xEE`
+> (`0x40` set as well) ACE stores `'\x01\0'` and resets `0x14` to `1`. LibRed matches the explicit case only.
+> On an OLE column flagged the same way the counter likewise takes a binary value's first four bytes: `01 02 03 04
+> 05 06` → `0x04030201`. With the table's own AutoNumber (`Categories.CategoryID`) beside it, an `INSERT` that
+> leaves that column out is refused *"You must enter a value in the 'Categories.CategoryID' field"*, its id
+> burned, and a one-byte binary value left `0x14` at the explicit `CategoryID` rather than taking the byte.
+> On a fixed column the width decides: a 4-byte `Single` takes its own bits (`0.25` → `0x3E800000`), while an
+> `Integer`, `Currency` or `Date/Time` column refuses the row, explicit value and all, with *"The field is too
+> small to accept the amount of data you attempted to add."* and `0x14` advanced by one — the id is drawn and
+> burned. DAO refuses to create the flag on a GUID column at all (`dbAutoIncrField` on `dbGUID`: *"Invalid
+> argument"*).
> **Reader/writer count guardrails.** LibRed validates the documented 255-column and 32-real-index
> limits before allocating count-sized structures, rejects negative logical/real index counts, and checks
@@ -252,6 +268,14 @@ the documented 255-column, 32-index, and 64-character-name limits.
> the first page's `0x04` next pointer is zeroed and it follows the single-page rule below (8 bytes zeroed
> past the new end, the rest left); a definition growing onto a second page keeps its first page and takes a
> fresh continuation. LibRed's `TableDefinition.WriteChain` does all of this.
+>
+> **Renaming an index (verified vs ACE).** The index's name entry is replaced, and its logical block moves with
+> it to where the new name sorts (§3.3, name order); the info block's bytes are unchanged, `index_num`
+> included. ACE writes the renamed definition **twice**, the same bytes both times. A single-page definition is
+> rewritten in place, so the second write changes nothing; a multi-page one's continuations take the lowest
+> free pages and then, since the first copy's pages are held until the statement ends, pages past them — from
+> free pages `56, 55` at the end of a 60-page file, `first → 56 → 55` and then `first → 61 → 60`, the first
+> copy left on its released pages.
### 3.3 Body layout (in order, after the header)
@@ -282,6 +306,15 @@ the documented 255-column, 32-index, and 64-character-name limits.
> FOREIGN KEY` is refused when the table already has an index of that name — *"Table 'FkC' already has an index
> named 'Taken'."*
>
+> A stored column name that holds a control character (U+0003, verified) still reads: the table opens and
+> `SELECT *` names the column as stored. Only the DDL refuses it, so a column renamed away from that name (DAO's
+> `Field.Name`) cannot be given it back — *"'…' is not a valid name."*
+>
+> Two columns stored under one name (verified, one name entry damaged into another's) still read. A lookup by
+> that name resolves to the first of them: `SELECT` of the name reads the first column's value, `SELECT *` lists
+> both as `Table.name`, and `CREATE INDEX` over the name indexes the first. `ADD COLUMN` of the name is refused,
+> *"Field '…' already exists in table '…'."*
+>
> LibRed enforces all of this on caller-supplied names via `JetName.Validate`, since writing the format
> directly bypasses ACE's DDL parser. Internal hidden names (the `.rN` incoming-relationship index names, §3.6)
> legitimately start with `.` and are **not** validated.
diff --git a/src/LibRed/docs/format/page-02b-columns.md b/src/LibRed/docs/format/page-02b-columns.md
index 2a6e11ef..9f3af419 100644
--- a/src/LibRed/docs/format/page-02b-columns.md
+++ b/src/LibRed/docs/format/page-02b-columns.md
@@ -6,7 +6,7 @@
| Offset | Size | Meaning |
| --- | --- | --- |
-| `0x00` | 1 | Data type (see §6) |
+| `0x00` | 1 | Data type (see §6). A code no type has does not refuse the table outright (verified): with `0x0D` or `0x0E` the table opens and counts, and only a read of that column fails — OLE DB's conversion errors, or *"Data type mismatch in criteria expression"* in a `WHERE`; with `0x15` everything that loads the table is *"Unrecognized database format"*. On `MSysRelationships.szColumn` (`0x0D`) every table still lists and reads and unrelated DDL runs, but the foreign-key list fails *"Cannot perform this operation"*; LibRed refuses reading the relationships the same way |
| `0x01` | 2 | Minimum engine build for the column, the low half of a 32-bit value (`0x03` is the high half) — `0x0659` as ACE and Jet 4.0 write it; each refuses the table when it exceeds its own build, 4518 and 9801 ([page-02a §3.1](page-02a-tdef.md) note) |
| `0x03` | 2 | The high half of the minimum-build field at `0x01`, which is 32 bits: non-zero here puts the build past ACE's, and ACE refuses the table — *"This object requires a newer version of the Microsoft Access database engine"* (verified). Write zero |
| `0x05` | 2 | Column id |
@@ -41,14 +41,21 @@ normally, but a compact drops the column, every column after it and every row of
> computed and stored, on an insert and on an update of a column it reads, while a Text or Memo one refuses both
> (*"Error evaluating CHECK constraint."*). An update that touches none of its inputs, and a delete, go through
> either way. A column with `0x40` and no expression at all fails before that, the table refusing to open
-> (*"Property not found"*), and a compact drops it. `0x80` alone does nothing: the column is an ordinary one, and
+> (*"Property not found"*), and a compact drops it — fixed-length or variable, everything that loads that table
+> fails so, its column schema included, while the table list and the other tables still read. On a **catalog**
+> table it depends which: `0x40` on any `MSysObjects` column, fixed or variable, and the database itself will not
+> open (*"Invalid database object reference."*); on `MSysRelationships` the foreign-key list fails *"Property not
+> found"* as a user table's reads do; on `MSysQueries` the database opens and lists no views at all. `0x80` alone
+> does nothing: the column is an ordinary one, and
> the bit goes at the next TDEF rewrite. A broken expression does not clear `0x80` — after `DROP COLUMN` of a
> column it reads, the flags stay `0xC0` and the error comes from the expression itself. Extended bit `0x02` is
> ignored and kept, through a rewrite and a compact alike.
>
> LibRed reads `0x40` as calculated and writes `0xC0`, as ACE does, and over `0x40` alone reads, writes, updates
> and deletes as ACE does (`ColumnDef.EvaluatesExpression`). An update or delete never reads a calculated
-> result, which is also what lets it rewrite a row whose result is a cached error.
+> result, which is also what lets it rewrite a row whose result is a cached error. A calculated column with no
+> `Expression` property refuses its table's definition, and one in `MSysObjects` refuses the catalog, both as
+> `InvalidDataException`; a damaged `MSysQueries` refuses too, where ACE lists no views.
>
> **Extended flags beyond `0x01`/`0xC0` belong to the complex columns (verified where set).** `0x10` is set on
> exactly the six attachment value columns — `FileData`, `FileFlags`, `FileName`, `FileTimeStamp`, `FileType`,
@@ -355,6 +362,16 @@ column's rank among the variable columns ordered by ascending id.
> read the dropped column's value). Why the gap is left, and what it means for writing a row rather than
> reading one, are [§3.1](page-02a-tdef.md#31-header) and [§5](page-01-data-and-rows.md) respectively.
+> **Two live columns naming one slot.** ACE does not check that variable indexes are distinct (verified on
+> Northwind's `Customers` with `City`'s index set to `CompanyName`'s, 0): the table opens and reads, and `City`
+> reads the company name, cut to `City`'s declared 15 characters in a `SELECT`. A write of `City` with that
+> value is refused as too large for the field, an update of another column succeeds, and an insert writes both
+> columns through the one slot, the later value winning. An index on `City` still holds each row under its
+> real city, so a write that has to move or remove that entry fails as the index section's missing-entry case
+> ([§10.4a](page-03-04-index-btree.md#104a-entry-removal--a-leaf-is-rewritten-not-repacked)). LibRed opens
+> and reads the table and refuses the same writes, but returns `City` whole (19 characters); whether ACE's cut
+> is the engine's or the OLE DB column binding's is not established.
+
#### Declared width limits
Two limits bind a declaration, both enforced by ACE when it **opens the file**, so writing past either
diff --git a/src/LibRed/docs/format/page-02d-constraints.md b/src/LibRed/docs/format/page-02d-constraints.md
index ca55ed85..5116c463 100644
--- a/src/LibRed/docs/format/page-02d-constraints.md
+++ b/src/LibRed/docs/format/page-02d-constraints.md
@@ -253,7 +253,8 @@ physical (data-block) index, prefer a real index's name over a foreign-key relat
> and a relationship's child index — whichever of a pair came first, and inside one `CREATE TABLE` as well. A
> flag or a column apart keeps them apart: plain beside unique, `IGNORE NULL` or `DISALLOW NULL`, ascending beside
> descending, a relationship beside a `UNIQUE` or the primary key over its column, a column list beside a prefix
-> of it. Dropping one of the names — `DROP INDEX`, or `DROP CONSTRAINT` for a relationship — takes only its
+> of it. A **one-to-one** relationship's child index is unique (`0x81`), so it is the `UNIQUE` index over its
+> columns that it shares, and it still keeps apart from the primary key (`0x89`) over them (verified vs DAO). Dropping one of the names — `DROP INDEX`, or `DROP CONSTRAINT` for a relationship — takes only its
> logical block and name; the data block, its statistics and its B-tree stay with the name that is left
> (verified). In a `CREATE TABLE` the constraint declared later is the one that shares: it takes no usage-map
> row and no root, so the rows and roots go to the others in declaration order as if it were not there
diff --git a/src/LibRed/docs/format/page-03-04-index-btree.md b/src/LibRed/docs/format/page-03-04-index-btree.md
index 3d0197e3..513c460c 100644
--- a/src/LibRed/docs/format/page-03-04-index-btree.md
+++ b/src/LibRed/docs/format/page-03-04-index-btree.md
@@ -691,10 +691,11 @@ to `n` bytes, as page-01 stores it. LibRed builds the row and every key from one
`ll`+`ll`. **Only Hungarian doubles** — a doubled digraph is written by doubling its first letter, so
`ggy` is `gy`+`gy` (`56 03 56 03`) and `ssz` is `sz`+`sz`, while Czech `cch` is plainly `c`+`ch`
(`4D 58 03`) and Spanish `cch` is `c`+`ch`. Doubling has to be tested *before* the plain longest match,
- or `ggy` degrades to `g`+`gy`. **Case breaks a contraction** where a lowercase letter is followed by an
- uppercase one inside it, and the match falls to a shorter one: `cS`, `sZ`, `gY`, `cH`, `lL`, `lJ` and `dŽ`
- are two letters each, Hungarian `dzS` is `dz`+`S` and `dZs` is `d`+`zs` — while `Cs`, `CS`, `Ch`, `Lj` and
- `Dž` contract, and so does a doubled `cCs` (verified in every digraph order). A contraction can carry a secondary of its own: Croatian `dž` is
+ or `ggy` degrades to `g`+`gy`. **A contraction matches only in lowercase, uppercase or title case**; any
+ other case mix falls to a shorter match: `cS`, `sZ`, `gY`, `cH`, `lL`, `lJ` and `dŽ` are two letters each,
+ Hungarian `dzS` is `dz`+`S`, `dZs` is `d`+`zs` and `DZs` is `DZ`+`s` — while `Cs`, `CS`, `Ch`, `Lj`, `Dž`,
+ `Dzs` and `DZS` contract, and so does a doubled `cCs`; a doubled `dDZs` is `dz`+`dz`+`s` (verified in every
+ case mix of every contraction). A contraction can carry a secondary of its own: Croatian `dž` is
`50 04` with secondary `04`, Danish `aa` is `å`'s primary with secondary `03`.
- **Expansion** — one character, several primaries. German Phone Book: `ä` = `7F 4A 51 01 00`, primaries
`a`+`e` (General has `a` + umlaut secondary); likewise `ö`→`o`+`e`, `ü`→`u`+`e`. Same primitive as
@@ -970,6 +971,13 @@ packing: where the prefix is longer than the key, there are no key bytes left to
Both engines then agree byte for byte: LibRed touches no page ACE does not (verified).
+> **An entry the row says is there, and is not.** The entry to remove is found by the key the row's stored
+> values encode to. When the index holds the row under another key — the file's index and table disagree —
+> ACE refuses the `UPDATE` that would move the entry, and the `DELETE` that would remove it, with *"The search
+> key was not found in any record."* and changes nothing (verified, on a `Customers` row whose `City` reads
+> another column's slot, §3 of [page-02b](page-02b-columns.md)). LibRed refuses both with
+> `InvalidDataException` and rolls the statement back.
+
### 10.4d A leaf the removal empties leaves the tree
An underfull leaf is left alone (§10.4a), but a leaf whose **last** entry is removed is taken out of the tree
diff --git a/src/LibRed/docs/format/page-05-usage-maps.md b/src/LibRed/docs/format/page-05-usage-maps.md
index 1c31bad4..97ae795e 100644
--- a/src/LibRed/docs/format/page-05-usage-maps.md
+++ b/src/LibRed/docs/format/page-05-usage-maps.md
@@ -234,6 +234,40 @@ the opening user's commit slot at close, and every later open fails with *"Unrec
A far larger page number is refused on the first open — from page 524,289 exactly, as measured on `0x1C`.
Only the page is checked on open — any row byte passes — but a `0x18` naming a record that is not a usage
map (page 0, a TDEF page, an ordinary data page) fails at the first allocation and damages the database.
+Aimed at a long-value row instead — row 0 of a 4,076-byte value, whose bytes read as an inline map starting at
+page 352,321,631 — the database opens and reads, and every statement needing a page fails *"Cannot open database
+''"* with the file left as it was: no page added, the long value untouched. An `INSERT` that had drawn its
+AutoNumber keeps it burned (verified). LibRed refuses to grow the file to any page past the 2 GiB limit, which
+refuses this one at the same point.
+
+**ACE does not look at the page the free map gives it (verified).** A `0x18` naming a table's own owned-pages
+map makes that table's pages free, and so does the page's bit set in the real free map; either way ACE allocates
+the page and writes over it. That held for a user table's page, a system table's, a page of the table the
+statement itself reads and writes, and one the connection had just scanned — a `CREATE TABLE` writes its
+definition there, an `INSERT` needing a long-value page writes one, and the rows on it are lost to a scan while
+`COUNT(*)` still answers from the TDEF's row count.
+
+Only some statements fail, and only on some tables' pages:
+
+- **`CREATE TABLE`** fails when it took a page of `MSysObjects` or `MSysACEs` — the two tables it inserts rows
+ into — with the write-conflict error ("…you and another user are attempting to change the same data at the
+ same time"). The page and the file are left intact. Taking a page of `MSysQueries` or `MSysRelationships`,
+ which it writes nothing to, succeeds.
+- **An `INSERT` writing a long value** fails with *"Unrecognized database format"* when the page it took is the
+ `MSysObjects` page holding its own table's row, or the one holding the database's and containers' rows (with
+ `MSysDb`). It fails after drawing the AutoNumber and before writing the row, leaves the page as it was, and
+ the file does not open again. Reading the table or its columns, or inserting a short row into it, on the same
+ connection first changes nothing. The same `INSERT` taking another `MSysObjects` page succeeds and writes its
+ long value over the catalog rows there, as does one taking a page of `MSysACEs` or `MSysRelationships`; so does
+ an `INSERT` that needs only data pages, onto any catalog page, its own table's row's included. Which of the
+ first page's rows the long-value write goes back to is not established.
+
+So ACE has no check that keeps a live page out of allocation; a statement fails when it goes back to the table
+whose page it took. LibRed allocates the same way. Where its statement goes back to such a page through a read
+that checks the page — `CREATE TABLE` inserting its catalog row on the `MSysObjects` page it has just made a
+definition — it refuses with `InvalidDataException` and rolls back, leaving the file intact as ACE does. Which
+page each engine takes, and what each goes back to, differ, so the two do not fail on the same cases: the
+`INSERT` that takes an `MSysObjects` page succeeds in LibRed and leaves the catalog damaged.
**Freed pages are released at close, through the released-pages map.** Most pages freed during a session are
not reusable on the same connection: later allocations in that session grow the file instead, and the free map on
@@ -279,6 +313,10 @@ An inline record that already covers them stays as it is. Otherwise, in order of
end and the vacated bytes are not cleared, so the long record's bitmap stays on the page below the new
one.
+An inline record whose start page is below 0 is not sized at all: with start page -2,147,483,648 and no bits set,
+releasing three pages and closing leaves the record as it was and merges the pages into the free map exactly as
+on the undamaged file (verified).
+
A map already in reference form gains a bitmap page, allocated the same way, for each range holding a released
page that it has none for — a released table-definition page among the free pages is taken like any other, its
type becoming `0x0105`. The merge then clears every bitmap page, each keeping its 4-byte header.
diff --git a/src/LibRed/docs/format/system-catalog.md b/src/LibRed/docs/format/system-catalog.md
index f905ffdd..79f29dfa 100644
--- a/src/LibRed/docs/format/system-catalog.md
+++ b/src/LibRed/docs/format/system-catalog.md
@@ -51,6 +51,13 @@
The last column lists what a row of that kind *can* carry, not what every one does: a query or relationship
written by ACE or LibRed leaves `LvProp` null (below), where Access fills it.
+ > **A table's row with a null `Id`, `Name` or `Flags`** (measured, by clearing the column's null-bitmap bit).
+ > The database still opens. A null **`Flags`** is no flags: the table reads as usual, and `MSysQueries`, its
+ > system bit gone, is listed as a `TABLE`. A null **`Id`** leaves the table listed but unreadable — *"Unrecognized
+ > database format"* — and on `MSysQueries` leaves no views at all. A null **`Name`** fails the table list
+ > (`E_FAIL`). LibRed reads a null `Flags` as `0` and refuses a table whose row has no `Id` or `Name` as
+ > `InvalidDataException`.
+
> **A name is unique within its container, and only there.** That is the rule the unique `(ParentId, Name)`
> index states, and the one ACE applies (verified, case-insensitively): a new table (`CREATE TABLE`,
> `SELECT … INTO`, a rename) or query (`CREATE VIEW` / `CREATE PROCEDURE`) is refused when a table, query or
@@ -837,6 +844,13 @@
single-column FK stores `ccolumn = 1`, `icolumn = 0`, `grbit = 0`; a relationship cascading both update
and delete stores `grbit = 0x1100`; Access's relationship dialog writes each bit above as its option says.
+ > **A relationship row with a null column** (measured, by clearing one column's null-bitmap bit in one row). The
+ > database opens, every table reads and DDL runs. The foreign-key list leaves out the relationship whose row has
+ > a null `szObject` or `szReferencedObject`, and lists it all the same with a null `szRelationship`, `szColumn`,
+ > `icolumn` or `grbit`. LibRed reads the relationships the same way. A column of another type than its own — a
+ > damaged type byte — fails the foreign-key list instead, *"Cannot perform this operation"*, and LibRed refuses
+ > the relationships as `InvalidDataException` ([page-02b §3.4](page-02b-columns.md)).
+
> **`grbit` records the relationship; ACE does not act on its cascade bits.** The update and delete actions
> ACE applies are the ones in the relationship's index-info blocks (§3.6, `0x15`/`0x16`): with the two made
> to disagree, a parent delete that `grbit` calls cascading but the blocks do not is refused, and one the
@@ -848,7 +862,13 @@
> are unique. On an **enforced** relationship the child's backing index is created **unique** with it, and
> non-unique without it even when the child column is the table's primary key. What ACE then enforces is
> that index's unique flag (page-02d §3.5, `0x2E`), not this bit: made to disagree, ACE follows the flag
- > (verified vs ACE). The bit is what Access and DAO report as the relationship's type.
+ > (verified vs ACE). The bit is what Access and DAO report as the relationship's type. A one-to-one differs
+ > from the same one-to-many in those two places only — `0x01` on every row of the key, and `0x81` for `0x80` on
+ > the child index — and DAO's one-to-many is byte-identical to SQL's `FOREIGN KEY` (verified). DAO refuses a
+ > one-to-one over child rows that already share a key (*"…would create duplicate values in the index, primary
+ > key, or relationship…"*); rows whose key is null do not collide. The refusal comes after the relationship's
+ > `MSysObjects` object and its `MSysACEs` rows are written, so their rollback leaves those two tables'
+ > counting behind (page-02a §3.1) and nothing else (verified, whole-file diff).
> **Writing a relationship.** An **enforced** relationship is `MSysRelationships` rows, an `MSysObjects`
> row of its own (`Type` = 8, under the relationship container, with the `MSysACEs` rows that container
@@ -906,6 +926,14 @@
> renamed**, which cannot collide with itself: ACE allows renaming a table to its own name, and allows a
> case-only change (both verified). The self-rename case is not hypothetical — EF models "move a table to
> another schema" as a rename, and on a schema-less engine that degrades to `RENAME TO` the *same* name.
+ >
+ > **Renaming an index (verified, through DAO's `Index.Name` — ACE has no SQL for it).** Only the table's
+ > definition changes; this table names no index. A primary key renames even while a relationship references
+ > it, the parent's incoming block untouched. Two renames are refused, leaving the file as it was: the index a
+ > relationship created on its child table (named after the relationship) — *"Cannot delete this index or table.
+ > It is either the current index or is used in a relationship."* — and a name another index of the table has —
+ > *"Index already exists."* A case-only change is the same index, and renames. The definition rewrite is in
+ > [page-02a](page-02a-tdef.md) §3.2.
- **MSysNameMap** is Access's **Name AutoCorrect** map: for each object Access tracks, the names it and the
objects it depends on had when the map was last written. Five columns, no indexes: `GUID` (GUID), `Id`
@@ -977,7 +1005,9 @@ Four layers — the user table, then three kinds of ordinary hidden/system table
2. **`MSysComplexColumns`** maps each complex column to its backing table:
`(ColumnName, ComplexID, ComplexTypeObjectID, ConceptualTableID, FlatTableID)`. E.g.
`Attachments | 3 | 39 | 79 | 150` = the `Attachments` column of table `79`, element type **39**
- (`MSysComplexType_Attachment`), backed by flat table **150** = `f__Attachments`.
+ (`MSysComplexType_Attachment`), backed by flat table **150** = `f__Attachments`. A write to a table
+ with no `Complex` column does not depend on it: with `ConceptualTableID`'s type byte damaged from Long to
+ Byte, ACE inserts, updates and deletes rows of such a table as usual (verified).
3. **`MSysComplexType_*`** — nine schema templates, one per element subtype, matching the DAO `dbComplex*`
codes: `UnsignedByte, Short, Long, IEEESingle, IEEEDouble, GUID, Decimal, Text, Attachment`.
`MSysComplexType_Attachment` = `FileData:Ole, FileFlags:Int32, FileName:Text, FileTimeStamp:DateTime,
diff --git a/test/EFCore.Jet.Data.Tests/RenameFanOutProbeTest.cs b/test/EFCore.Jet.Data.Tests/RenameFanOutProbeTest.cs
index 259896f9..4c964194 100644
--- a/test/EFCore.Jet.Data.Tests/RenameFanOutProbeTest.cs
+++ b/test/EFCore.Jet.Data.Tests/RenameFanOutProbeTest.cs
@@ -211,6 +211,59 @@ CREATE TABLE DocChild (Id INT NOT NULL CONSTRAINT PK_DocChild PRIMARY KEY, DocId
Assert.IsFalse(ViewResolves("vwDoc"), "The view still resolves — ACE rewrote the stored query.");
}
+ ///
+ /// The index-rename counterpart, through the intercepted DAO path. Measured against ACE
+ /// (RenameIndexDaoProbeTest): a plain index and a primary key rename — the key in place even while a
+ /// relationship references it — but the index a relationship created on its child table is refused, as is
+ /// a name another index of the table has.
+ ///
+ [TestMethod]
+ public void Probe_what_an_index_rename_does()
+ {
+ string plain = TryRenameIndex("Parent", "IX_Parent_Name", "IX_Parent_Name_Renamed");
+ string key = TryRenameIndex("Parent", "PK_Parent", "PK_Parent_Renamed");
+ string relationship = TryRenameIndex("Child", "FK_Child_Parent", "FK_Child_Parent_Renamed");
+ string taken = TryRenameIndex("Child", "PK_Child", "FK_Child_Parent");
+
+ ReOpenConnection();
+
+ Report($"rename plain index : {plain}");
+ Report($"rename referenced key : {key}");
+ Report($"rename FK's own index : {relationship}");
+ Report($"rename onto taken name : {taken}");
+ ReportIndexes();
+ ReportRelations();
+
+ Assert.AreEqual("ALLOWED (no error)", plain);
+ Assert.IsTrue(IndexExists("Parent", "IX_Parent_Name_Renamed"), "The plain index was not renamed.");
+ Assert.IsFalse(IndexExists("Parent", "IX_Parent_Name"), "The old index name still resolves.");
+
+ Assert.AreEqual("ALLOWED (no error)", key);
+ Assert.IsTrue(IndexExists("Parent", "PK_Parent_Renamed"), "The primary key was not renamed.");
+ Assert.AreEqual("True", RelationValue("FK_Child_Parent", "IS_ENFORCED"), ignoreCase: true,
+ "The relationship lost its enforcement when its referenced key was renamed.");
+
+ Assert.IsTrue(relationship.StartsWith("REJECTED"), $"ACE renamed a relationship's own index: {relationship}");
+ Assert.IsTrue(IndexExists("Child", "FK_Child_Parent"), "The relationship's index lost its name.");
+
+ Assert.IsTrue(taken.StartsWith("REJECTED"), $"ACE renamed an index onto a name another index has: {taken}");
+ Assert.IsTrue(IndexExists("Child", "PK_Child"), "The primary key lost its name.");
+ }
+
+ private string TryRenameIndex(string table, string from, string to)
+ {
+ try
+ {
+ using var command = _connection.CreateCommand($"ALTER TABLE `{table}` RENAME INDEX `{from}` TO `{to}`");
+ command.ExecuteNonQuery();
+ return "ALLOWED (no error)";
+ }
+ catch (Exception e)
+ {
+ return $"REJECTED — {e.GetType().Name}: {e.GetBaseException().Message.ReplaceLineEndings(" ")}";
+ }
+ }
+
/// A single field of the named relationship's column mapping, or null if it is gone.
private string RelationColumnValue(string relationName, string columnName)
{
diff --git a/test/EFCore.Jet.FunctionalTests/Query/AdHocQueryFiltersQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/AdHocQueryFiltersQueryJetTest.cs
index 94ca63bd..57a085f0 100644
--- a/test/EFCore.Jet.FunctionalTests/Query/AdHocQueryFiltersQueryJetTest.cs
+++ b/test/EFCore.Jet.FunctionalTests/Query/AdHocQueryFiltersQueryJetTest.cs
@@ -509,20 +509,6 @@ public override async Task Named_query_filters_combined()
AssertSql();
}
- public override async Task Query_filter_with_EF_Constant_throws()
- {
- await base.Query_filter_with_EF_Constant_throws();
-
- AssertSql();
- }
-
- public override async Task Query_filter_with_EF_Parameter_throws()
- {
- await base.Query_filter_with_EF_Parameter_throws();
-
- AssertSql();
- }
-
public override async Task GroupBy_aggregate_over_required_navigation_with_query_filter(bool async)
{
await base.GroupBy_aggregate_over_required_navigation_with_query_filter(async);
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionJetTest.cs
new file mode 100644
index 00000000..9a7ede1d
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionJetTest.cs
@@ -0,0 +1,102 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.ComplexTableSplitting;
+
+public class ComplexTableSplittingPrimitiveCollectionJetTest(
+ ComplexTableSplittingJetFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : ComplexTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateJetTest.cs
new file mode 100644
index 00000000..94788daa
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateJetTest.cs
@@ -0,0 +1,158 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System;
+using System.Data.Common;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Sdk;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsBulkUpdateJetTest(NavigationsJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsBulkUpdateRelationalTestBase(fixture, testOutputHelper)
+{
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ // FK constraint failures
+ public override Task Delete_entity_with_associations()
+ => Assert.ThrowsAsync(base.Delete_entity_with_associations);
+
+ public override Task Delete_required_associate()
+ => Assert.ThrowsAsync(base.Delete_required_associate);
+
+ // SQL generation produces invalid object name for these scenarios
+ public override Task Delete_optional_associate()
+ => Assert.ThrowsAsync(base.Delete_optional_associate);
+
+ public override Task Update_property_inside_associate()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate);
+
+ public override Task Update_property_inside_associate_with_special_chars()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate_with_special_chars);
+
+ public override Task Update_property_on_projected_associate()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate);
+
+ public override Task Update_property_on_projected_associate_with_OrderBy_Skip()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate_with_OrderBy_Skip);
+
+ public override Task Update_multiple_properties_inside_same_associate()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_same_associate);
+
+ public override Task Update_primitive_collection_to_constant()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_constant);
+
+ public override Task Update_primitive_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_parameter);
+
+ // Translation not yet supported for navigation-mapped associations
+ public override Task Update_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_parameter);
+
+ public override Task Update_associate_to_inline()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline);
+
+ public override Task Update_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline_with_lambda);
+
+ public override Task Update_associate_to_another_associate()
+ => Assert.ThrowsAsync(base.Update_associate_to_another_associate);
+
+ public override Task Update_associate_to_null()
+ => Assert.ThrowsAsync(base.Update_associate_to_null);
+
+ public override Task Update_associate_to_null_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_with_lambda);
+
+ public override Task Update_associate_to_null_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_parameter);
+
+ public override Task Update_nested_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_parameter);
+
+ public override Task Update_nested_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_inline_with_lambda);
+
+ public override Task Update_nested_associate_to_another_nested_associate()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_another_nested_associate);
+
+ public override Task Update_nested_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_parameter);
+
+ public override Task Update_nested_collection_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_inline_with_lambda);
+
+ public override Task Update_nested_collection_to_another_nested_collection()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_another_nested_collection);
+
+ public override Task Update_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_collection_to_parameter);
+
+ public override Task Update_collection_referencing_the_original_collection()
+ => Assert.ThrowsAsync(base.Update_collection_referencing_the_original_collection);
+
+ public override Task Update_primitive_collection_to_another_collection()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_another_collection);
+
+ public override Task Update_inside_structural_collection()
+ => Assert.ThrowsAsync(base.Update_inside_structural_collection);
+
+ public override Task Update_multiple_properties_inside_associates_and_on_entity_type()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_associates_and_on_entity_type);
+
+ public override Task Update_multiple_projected_associates_via_anonymous_type()
+ => Assert.ThrowsAsync(base.Update_multiple_projected_associates_via_anonymous_type);
+
+ public override async Task Update_property_inside_nested_associate()
+ {
+ await base.Update_property_inside_nested_associate();
+
+ AssertExecuteUpdateSql(
+ """
+@p='foo_updated' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [n]
+SET [n].[String] = @p
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [NestedAssociateType] AS [n] ON [a].[RequiredNestedAssociateId] = [n].[Id]
+""");
+ }
+
+ public override async Task Update_associate_with_null_required_property()
+ {
+ await base.Update_associate_with_null_required_property();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_required_nested_associate_to_null()
+ {
+ await base.Update_required_nested_associate_to_null();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_inside_primitive_collection()
+ {
+ await base.Update_inside_primitive_collection();
+
+ AssertExecuteUpdateSql(
+ """
+@p='99'
+
+SET NOCOUNT OFF;
+UPDATE [a0]
+SET [a0].[Ints] = JSON_MODIFY([a0].[Ints], '$[1]', @p)
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [AssociateType] AS [a0] ON [r].[RequiredAssociateId] = [a0].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) >= 2
+""");
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionJetTest.cs
new file mode 100644
index 00000000..c617fdbf
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionJetTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsPrimitiveCollectionJetTest(NavigationsJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE CAST(JSON_VALUE([a].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [NestedAssociateType] AS [n] ON [a].[RequiredNestedAssociateId] = [n].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[OptionalNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a0].[RequiredNestedAssociateId] = [n1].[Id]
+LEFT JOIN [NestedAssociateType] AS [n2] ON [a].[OptionalNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([n].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionJetTest.cs
new file mode 100644
index 00000000..b2b1a5db
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionJetTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.OwnedNavigations;
+
+public class OwnedNavigationsPrimitiveCollectionJetTest(OwnedNavigationsJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : OwnedNavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r0].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r0].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r1].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionJetTest.cs
new file mode 100644
index 00000000..55ea789e
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionJetTest.cs
@@ -0,0 +1,152 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Associations.OwnedTableSplitting;
+
+public class OwnedTableSplittingPrimitiveCollectionJetTest(
+ OwnedTableSplittingJetFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : OwnedTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r2].[AssociateTypeRootEntityId], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r0].[RootEntityId], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r1].[AssociateTypeRootEntityId], [r1].[AssociateTypeId], [r1].[Id] AS [Id0], [r1].[Int] AS [Int0], [r1].[Ints] AS [Ints0], [r1].[Name] AS [Name0], [r1].[String] AS [String0], [r0].[OptionalNestedAssociate_Id], [r0].[OptionalNestedAssociate_Int], [r0].[OptionalNestedAssociate_Ints], [r0].[OptionalNestedAssociate_Name], [r0].[OptionalNestedAssociate_String], [r0].[RequiredNestedAssociate_Id], [r0].[RequiredNestedAssociate_Int], [r0].[RequiredNestedAssociate_Ints], [r0].[RequiredNestedAssociate_Name], [r0].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r0]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId] AND [r0].[Id] = [r1].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r2] ON [r].[Id] = [r2].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r2].[AssociateTypeRootEntityId], [r2].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetFixture.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetFixture.cs
new file mode 100644
index 00000000..83156949
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryJetFixture : TPCInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetTest.cs
new file mode 100644
index 00000000..f3fd8f84
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryJetTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryJetTest(TPCInheritanceJsonQueryJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[ParentComplexType]
+FROM (
+ SELECT [d].[ParentComplexType]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[ParentComplexType]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[ParentComplexType]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[ParentComplexType]
+ FROM [Tea] AS [t]
+) AS [u]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([u].[ParentComplexType], '$.Nested')
+FROM (
+ SELECT [d].[ParentComplexType]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[ParentComplexType]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[ParentComplexType]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[ParentComplexType]
+ FROM [Tea] AS [t]
+) AS [u]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryJetTest.cs
new file mode 100644
index 00000000..b6524226
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryJetTest.cs
@@ -0,0 +1,175 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceTableSplittingQueryJetTest(TPCInheritanceQueryJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+WHERE [c].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE [u].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+WHERE [c].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE [u].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+UNION ALL
+SELECT [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+UNION ALL
+SELECT [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Lilt] AS [l]
+UNION ALL
+SELECT [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Tea] AS [t]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+UNION ALL
+SELECT [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+UNION ALL
+SELECT [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Lilt] AS [l]
+UNION ALL
+SELECT [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Tea] AS [t]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetFixture.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetFixture.cs
new file mode 100644
index 00000000..bcc605cd
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryJetFixture : TPHInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetTest.cs
new file mode 100644
index 00000000..b616a6f3
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryJetTest.cs
@@ -0,0 +1,122 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryJetTest(TPHInheritanceJsonQueryJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPHInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryJetTest.cs
new file mode 100644
index 00000000..0f5b3d4a
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryJetTest.cs
@@ -0,0 +1,125 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceTableSplittingQueryJetTest(
+ TPHInheritanceQueryJetFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPHInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetFixture.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetFixture.cs
new file mode 100644
index 00000000..2a028733
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryJetFixture : TPTInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetTest.cs
new file mode 100644
index 00000000..57d513b7
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryJetTest.cs
@@ -0,0 +1,145 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryJetTest(TPTInheritanceJsonQueryJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPTInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryJetTest.cs
new file mode 100644
index 00000000..ebb2fe47
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryJetTest.cs
@@ -0,0 +1,148 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceTableSplittingQueryJetTest(
+ TPTInheritanceQueryJetFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPTInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE [c].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE [d].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE [c].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE [d].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Query/Translations/JsonTranslationsJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/Translations/JsonTranslationsJetTest.cs
new file mode 100644
index 00000000..92b9a42e
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Query/Translations/JsonTranslationsJetTest.cs
@@ -0,0 +1,70 @@
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Translations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Query.Translations;
+
+public class JsonTranslationsJetTest : JsonTranslationsRelationalTestBase<
+ JsonTranslationsJetTest.JsonTranslationsQueryJetFixture>
+{
+ public JsonTranslationsJetTest(JsonTranslationsQueryJetFixture fixture, ITestOutputHelper testOutputHelper)
+ : base(fixture)
+ {
+ Fixture.TestSqlLoggerFactory.Clear();
+ Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
+ }
+
+ public override async Task JsonPathExists_on_scalar_string_column()
+ {
+ await base.JsonPathExists_on_scalar_string_column();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonString], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_complex_property()
+ {
+ await base.JsonPathExists_on_complex_property();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonComplexType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_owned_entity()
+ {
+ await base.JsonPathExists_on_owned_entity();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonOwnedType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public class JsonTranslationsQueryJetFixture : JsonTranslationsQueryFixtureBase, ITestSqlLoggerFactory
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+
+ protected override string RemoveJsonProperty(string column, string property)
+ => $"JSON_MODIFY({column}, '$.{property}', NULL)";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ private void AssertSql(params string[] expected)
+ => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
+}
diff --git a/test/EFCore.Jet.FunctionalTests/RuntimeMigrationJetTest.cs b/test/EFCore.Jet.FunctionalTests/RuntimeMigrationJetTest.cs
new file mode 100644
index 00000000..bb566d41
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/RuntimeMigrationJetTest.cs
@@ -0,0 +1,20 @@
+using EntityFrameworkCore.Jet.Design.Internal;
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Reflection;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests;
+
+public class RuntimeMigrationJetTest(RuntimeMigrationJetTest.RuntimeMigrationJetFixture fixture)
+ : RuntimeMigrationTestBase(fixture)
+{
+ protected override Assembly ProviderAssembly
+ => typeof(JetDesignTimeServices).Assembly;
+
+ public class RuntimeMigrationJetFixture : RuntimeMigrationFixtureBase
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/JetTypeFixture.cs b/test/EFCore.Jet.FunctionalTests/Types/JetTypeFixture.cs
new file mode 100644
index 00000000..0b9a1e9a
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/JetTypeFixture.cs
@@ -0,0 +1,14 @@
+using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types;
+
+public abstract class JetTypeFixture : RelationalTypeFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => JetTestStoreFactory.Instance;
+
+ public virtual bool UsingJsonType
+ => false;
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetBoolTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetBoolTypeTest.cs
new file mode 100644
index 00000000..56873c3e
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetBoolTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Miscellaneous;
+
+public class JetBoolTypeTest(JetBoolTypeTest.BoolTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(1 AS bit)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='True'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bit '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='False'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bit) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bit) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":false,"Value":false}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class BoolTypeFixture : JetTypeFixture
+ {
+ public override bool Value { get; } = true;
+ public override bool OtherValue { get; } = false;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetByteArrayTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetByteArrayTypeTest.cs
new file mode 100644
index 00000000..863ddbbe
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetByteArrayTypeTest.cs
@@ -0,0 +1,220 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Miscellaneous;
+
+public class JetByteArrayTypeTest(JetByteArrayTypeTest.ByteArrayTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 8000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 0x010203
+""");
+ }
+
+ // byte[].Equals() does reference equality, so the base test doesn't work for byte arrays
+ public override Task Primitive_collection_in_query()
+ => Task.CompletedTask;
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='0x04050607' (Size = 8000)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with varbinary even on SQL Server 2025, as that type isn't supported
+ // (#36627).
+ // We also can't just wrap JSON_VALUE() with CAST(... AS varbinary(max)), as that would apply a SQL Server binary format
+ // conversion, and not base64. So we use OPENJSON which does perform base64 conversion.
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 8000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+OUTER APPLY OPENJSON([j].[JsonContainer]) WITH ([Value] varbinary(max) '$.Value') AS [v]
+WHERE [v].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"BAUGBw==","Value":"BAUGBw=="}' (Nullable = false) (Size = 44)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteArrayTypeFixture : JetTypeFixture
+ {
+ public override byte[] Value { get; } = [1, 2, 3];
+ public override byte[] OtherValue { get; } = [4, 5, 6, 7];
+
+ public override Func Comparer { get; } = (a, b) => a.SequenceEqual(b);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetGuidTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetGuidTypeTest.cs
new file mode 100644
index 00000000..fac28920
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetGuidTypeTest.cs
@@ -0,0 +1,227 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Miscellaneous;
+
+public class JetGuidTypeTest(JetGuidTypeTest.GuidTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '8f7331d6-cde9-44fb-8611-81fff686f280'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] uniqueidentifier '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='ae192c36-9004-49b2-b785-8be10d169627'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with uniqueidentifier even on SQL Server 2025, as that type isn't
+ // supported (#36627).
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS uniqueidentifier) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"ae192c36-9004-49b2-b785-8be10d169627","Value":"ae192c36-9004-49b2-b785-8be10d169627"}' (Nullable = false) (Size = 100)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class GuidTypeFixture : JetTypeFixture
+ {
+ public override Guid Value { get; } = new("8f7331d6-cde9-44fb-8611-81fff686f280");
+ public override Guid OtherValue { get; } = new("ae192c36-9004-49b2-b785-8be10d169627");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetStringTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetStringTypeTest.cs
new file mode 100644
index 00000000..e21ef4da
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Miscellaneous/JetStringTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Miscellaneous;
+
+public class JetStringTypeTest(JetStringTypeTest.StringTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = N'foo'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='foo' (Size = 4000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] nvarchar(max) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='bar' (Size = 4000)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING nvarchar(max)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value') = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"bar","Value":"bar"}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class StringTypeFixture : JetTypeFixture
+ {
+ public override string Value { get; } = "foo";
+ public override string OtherValue { get; } = "bar";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetByteTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetByteTypeTest.cs
new file mode 100644
index 00000000..c6669c59
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetByteTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetByteTypeTest(JetByteTypeTest.ByteTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(0 AS tinyint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='0' (Size = 1)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] tinyint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='255' (Size = 1)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING tinyint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS tinyint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":255,"Value":255}' (Nullable = false) (Size = 30)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteTypeFixture : JetTypeFixture
+ {
+ public override byte Value { get; } = byte.MinValue;
+ public override byte OtherValue { get; } = byte.MaxValue;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDecimalTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDecimalTypeTest.cs
new file mode 100644
index 00000000..0a889371
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDecimalTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetDecimalTypeTest(JetDecimalTypeTest.DecimalTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 30.5
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] decimal(18,2) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30' (Precision = 18) (Scale = 2)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING decimal(18,2)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS decimal(18,2)) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DecimalTypeFixture : JetTypeFixture
+ {
+ public override decimal Value { get; } = 30.5m;
+ public override decimal OtherValue { get; } = 30m;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDoubleTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDoubleTypeTest.cs
new file mode 100644
index 00000000..63530063
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetDoubleTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetDoubleTypeTest(JetDoubleTypeTest.DoubleTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 30.5E0
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] float '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING float) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS float) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DoubleTypeFixture : JetTypeFixture
+ {
+ public override double Value { get; } = 30.5d;
+ public override double OtherValue { get; } = 30d;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetFloatTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetFloatTypeTest.cs
new file mode 100644
index 00000000..1d58b760
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetFloatTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetFloatTypeTest(JetFloatTypeTest.FloatTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(30.5 AS real)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] real '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING real) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS real) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class FloatTypeFixture : JetTypeFixture
+ {
+ public override float Value { get; } = 30.5f;
+ public override float OtherValue { get; } = 30f;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetIntTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetIntTypeTest.cs
new file mode 100644
index 00000000..b91e050c
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetIntTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetIntTypeTest(JetIntTypeTest.IntTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = -2147483648
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-2147483648'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] int '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2147483647'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING int) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS int) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":2147483647,"Value":2147483647}' (Nullable = false) (Size = 44)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class IntTypeFixture : JetTypeFixture
+ {
+ public override int Value { get; } = int.MinValue;
+ public override int OtherValue { get; } = int.MaxValue;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetLongTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetLongTypeTest.cs
new file mode 100644
index 00000000..cdf0ab18
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetLongTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetLongTypeTest(JetLongTypeTest.LongTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(-9223372036854775808 AS bigint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-9223372036854775808'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bigint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='9223372036854775807'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bigint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bigint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":9223372036854775807,"Value":9223372036854775807}' (Nullable = false) (Size = 62)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class LongTypeFixture : JetTypeFixture
+ {
+ public override long Value { get; } = long.MinValue;
+ public override long OtherValue { get; } = long.MaxValue;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetShortTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetShortTypeTest.cs
new file mode 100644
index 00000000..07bc9f7e
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Numeric/JetShortTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Numeric;
+
+public class JetShortTypeTest(JetShortTypeTest.ShortTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(-32768 AS smallint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-32768'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] smallint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='32767'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING smallint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS smallint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":32767,"Value":32767}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ShortTypeFixture : JetTypeFixture
+ {
+ public override short Value { get; } = short.MinValue;
+ public override short OtherValue { get; } = short.MaxValue;
+ }
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateOnlyTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateOnlyTypeTest.cs
new file mode 100644
index 00000000..a20b0e83
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateOnlyTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetDateOnlyTypeTest(JetDateOnlyTypeTest.DateTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] date '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='05/03/2022' (DbType = Date)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING date) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS date) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03","Value":"2022-05-03"}' (Nullable = false) (Size = 48)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTypeFixture : JetTypeFixture
+ {
+ public override DateOnly Value { get; } = new(2020, 1, 5);
+ public override DateOnly OtherValue { get; } = new(2022, 5, 3);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTime2TypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTime2TypeTest.cs
new file mode 100644
index 00000000..dbdd8eb8
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTime2TypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetDateTime2TypeTest(JetDateTime2TypeTest.DateTime2TypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.0000000'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime2 '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetime2) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime2) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTime2TypeFixture : JetTypeFixture
+ {
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeOffsetTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeOffsetTypeTest.cs
new file mode 100644
index 00000000..cb95f948
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeOffsetTypeTest.cs
@@ -0,0 +1,241 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetDateTimeOffsetTypeTest(
+ JetDateTimeOffsetTypeTest.DateTimeOffsetTypeFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.0000000+02:00'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetimeoffset '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2020-01-05T12:30:45.0000000+03:00'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetimeoffset) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetimeoffset) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2020-01-05T12:30:45+03:00","Value":"2020-01-05T12:30:45+03:00"}' (Nullable = false) (Size = 78)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeOffsetTypeFixture : JetTypeFixture
+ {
+ public override DateTimeOffset Value { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(2));
+ public override DateTimeOffset OtherValue { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(3));
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeTypeTest.cs
new file mode 100644
index 00000000..b15753ba
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetDateTimeTypeTest.cs
@@ -0,0 +1,229 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetDateTimeTypeTest(JetDateTimeTypeTest.DateTimeTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.000'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000' (DbType = DateTime)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeTypeFixture : JetTypeFixture
+ {
+ // The default mapping for .NET DateTime is datetime2; this tests the non-default (and discouraged) datetime type.
+ public override string StoreType
+ => "datetime";
+
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeOnlyTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeOnlyTypeTest.cs
new file mode 100644
index 00000000..f6a1869c
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeOnlyTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetTimeOnlyTypeTest(JetTimeOnlyTypeTest.TimeOnlyTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '12:30:45'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='12:30' (DbType = Time)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] time '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='14:00' (DbType = Time)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING time) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS time) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"14:00:00.0000000","Value":"14:00:00.0000000"}' (Nullable = false) (Size = 60)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class TimeOnlyTypeFixture : JetTypeFixture
+ {
+ public override TimeOnly Value { get; } = new(12, 30, 45);
+ public override TimeOnly OtherValue { get; } = new(14, 0, 0);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeSpanTypeTest.cs b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeSpanTypeTest.cs
new file mode 100644
index 00000000..9cd8be76
--- /dev/null
+++ b/test/EFCore.Jet.FunctionalTests/Types/Temporal/JetTimeSpanTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.Jet.FunctionalTests.Types.Temporal;
+
+public class JetTimeSpanTypeTest(JetTimeSpanTypeTest.TimeSpanTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '12:30:45'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='12:30:45'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] time '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='14:00:00'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING time) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS time) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"14:00:00","Value":"14:00:00"}' (Nullable = false) (Size = 44)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'14:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'14:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class TimeSpanTypeFixture : JetTypeFixture
+ {
+ public override TimeSpan Value { get; } = new(12, 30, 45);
+ public override TimeSpan OtherValue { get; } = new(14, 0, 0);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Context.cs b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Context.cs
new file mode 100644
index 00000000..6d71acb6
--- /dev/null
+++ b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Context.cs
@@ -0,0 +1,27 @@
+using System.Data.Common;
+using Microsoft.EntityFrameworkCore;
+
+namespace EntityFrameworkCore.Jet.IntegrationTests.Model80_LongValuesOverOdbc
+{
+ public class Context : DbContext
+ {
+ public Context(DbConnection connection) :
+ base(TestBase.GetContextOptions(connection))
+ {
+ TestBase.TryCreateTables(this);
+ }
+
+ public DbSet Table { get; set; }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(
+ b =>
+ {
+ b.Property(x => x.Text).HasColumnType("longchar");
+ b.Property(x => x.Binary).HasColumnType("longbinary");
+ b.ComplexProperty(x => x.Document, d => d.ToJson());
+ });
+ }
+ }
+}
diff --git a/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/JetTest.cs b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/JetTest.cs
new file mode 100644
index 00000000..5e52518a
--- /dev/null
+++ b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/JetTest.cs
@@ -0,0 +1,19 @@
+using System.Data.Common;
+using System.Data.Odbc;
+using EntityFrameworkCore.Jet.Data;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace EntityFrameworkCore.Jet.IntegrationTests.Model80_LongValuesOverOdbc
+{
+ [TestClass]
+ public class Model80_LongValuesOverOdbc : Test
+ {
+ // ODBC explicitly: the bug is the Access ODBC driver's, so the test must not follow the default provider.
+ protected override DbConnection GetConnection(string storeName)
+ {
+ var connection = new JetConnection(Helpers.CreateJetDatabase(storeName), OdbcFactory.Instance);
+ connection.Open();
+ return connection;
+ }
+ }
+}
diff --git a/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Table.cs b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Table.cs
new file mode 100644
index 00000000..6aba3250
--- /dev/null
+++ b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Table.cs
@@ -0,0 +1,15 @@
+namespace EntityFrameworkCore.Jet.IntegrationTests.Model80_LongValuesOverOdbc
+{
+ public class Table
+ {
+ public int Id { get; set; }
+ public string Text { get; set; }
+ public byte[] Binary { get; set; }
+ public Document Document { get; set; }
+ }
+
+ public class Document
+ {
+ public string Body { get; set; }
+ }
+}
diff --git a/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Test.cs b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Test.cs
new file mode 100644
index 00000000..428a89a9
--- /dev/null
+++ b/test/EFCore.Jet.IntegrationTests/Model80_LongValuesOverOdbc/Test.cs
@@ -0,0 +1,85 @@
+using System.Data.Common;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace EntityFrameworkCore.Jet.IntegrationTests.Model80_LongValuesOverOdbc
+{
+ // The Access ODBC driver refuses a string parameter longer than 255 characters, and a binary one longer than
+ // 510 bytes, with HY104 "Invalid precision value" unless it is bound as a long type (GitHub issue #306).
+ public abstract class Test
+ {
+ // One database per test method: MSTest runs them in parallel.
+ protected abstract DbConnection GetConnection(string storeName);
+
+ [TestMethod]
+ public void Model80_LongValuesOverOdbc_Insert()
+ {
+ using var connection = GetConnection("Model80_LongValuesOverOdbc_Insert.accdb");
+ using (var context = new Context(connection))
+ {
+ context.Table.Add(
+ new Table
+ {
+ Text = new string('a', 256),
+ Binary = Enumerable.Range(0, 511).Select(i => (byte)i).ToArray(),
+ Document = new Document { Body = new string('b', 300) }
+ });
+ context.SaveChanges();
+ }
+
+ using (var context = new Context(connection))
+ {
+ var row = context.Table.Single();
+ Assert.AreEqual(new string('a', 256), row.Text);
+ CollectionAssert.AreEqual(Enumerable.Range(0, 511).Select(i => (byte)i).ToArray(), row.Binary);
+ Assert.AreEqual(new string('b', 300), row.Document.Body);
+ }
+ }
+
+ [TestMethod]
+ public void Model80_LongValuesOverOdbc_Update()
+ {
+ using var connection = GetConnection("Model80_LongValuesOverOdbc_Update.accdb");
+ using (var context = new Context(connection))
+ {
+ context.Table.Add(new Table { Text = "short", Binary = [1, 2, 3], Document = new Document { Body = "short" } });
+ context.SaveChanges();
+ }
+
+ using (var context = new Context(connection))
+ {
+ var row = context.Table.Single();
+ row.Text = new string('a', 300);
+ row.Binary = new byte[8001];
+ row.Document = new Document { Body = new string('b', 300) };
+ context.SaveChanges();
+ }
+
+ using (var context = new Context(connection))
+ {
+ var row = context.Table.Single();
+ Assert.AreEqual(new string('a', 300), row.Text);
+ Assert.AreEqual(8001, row.Binary.Length);
+ Assert.AreEqual(new string('b', 300), row.Document.Body);
+ }
+ }
+
+ [TestMethod]
+ public void Model80_LongValuesOverOdbc_Where()
+ {
+ using var connection = GetConnection("Model80_LongValuesOverOdbc_Where.accdb");
+ using (var context = new Context(connection))
+ {
+ context.Table.Add(new Table { Text = new string('a', 300), Document = new Document { Body = "x" } });
+ context.Table.Add(new Table { Text = "short", Document = new Document { Body = "y" } });
+ context.SaveChanges();
+ }
+
+ using (var context = new Context(connection))
+ {
+ var value = new string('a', 300);
+ Assert.AreEqual(1, context.Table.Count(x => x.Text == value));
+ }
+ }
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
index c6169e1e..38eb490b 100644
--- a/test/EFCore.LibRed.Extended.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
@@ -511,20 +511,6 @@ public override async Task Named_query_filters_combined()
AssertSql();
}
- public override async Task Query_filter_with_EF_Constant_throws()
- {
- await base.Query_filter_with_EF_Constant_throws();
-
- AssertSql();
- }
-
- public override async Task Query_filter_with_EF_Parameter_throws()
- {
- await base.Query_filter_with_EF_Parameter_throws();
-
- AssertSql();
- }
-
public override async Task GroupBy_aggregate_over_required_navigation_with_query_filter(bool async)
{
await base.GroupBy_aggregate_over_required_navigation_with_query_filter(async);
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..178ca109
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,102 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Associations.ComplexTableSplitting;
+
+public class ComplexTableSplittingPrimitiveCollectionLibRedTest(
+ ComplexTableSplittingLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : ComplexTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs
new file mode 100644
index 00000000..75c3ab7b
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs
@@ -0,0 +1,156 @@
+using System;
+using System.Data.Common;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+using Xunit.Sdk;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsBulkUpdateLibRedTest(NavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsBulkUpdateRelationalTestBase(fixture, testOutputHelper)
+{
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ // FK constraint failures
+ public override Task Delete_entity_with_associations()
+ => Assert.ThrowsAsync(base.Delete_entity_with_associations);
+
+ public override Task Delete_required_associate()
+ => Assert.ThrowsAsync(base.Delete_required_associate);
+
+ // SQL generation produces invalid object name for these scenarios
+ public override Task Delete_optional_associate()
+ => Assert.ThrowsAsync(base.Delete_optional_associate);
+
+ public override Task Update_property_inside_associate()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate);
+
+ public override Task Update_property_inside_associate_with_special_chars()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate_with_special_chars);
+
+ public override Task Update_property_on_projected_associate()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate);
+
+ public override Task Update_property_on_projected_associate_with_OrderBy_Skip()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate_with_OrderBy_Skip);
+
+ public override Task Update_multiple_properties_inside_same_associate()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_same_associate);
+
+ public override Task Update_primitive_collection_to_constant()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_constant);
+
+ public override Task Update_primitive_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_parameter);
+
+ // Translation not yet supported for navigation-mapped associations
+ public override Task Update_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_parameter);
+
+ public override Task Update_associate_to_inline()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline);
+
+ public override Task Update_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline_with_lambda);
+
+ public override Task Update_associate_to_another_associate()
+ => Assert.ThrowsAsync(base.Update_associate_to_another_associate);
+
+ public override Task Update_associate_to_null()
+ => Assert.ThrowsAsync(base.Update_associate_to_null);
+
+ public override Task Update_associate_to_null_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_with_lambda);
+
+ public override Task Update_associate_to_null_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_parameter);
+
+ public override Task Update_nested_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_parameter);
+
+ public override Task Update_nested_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_inline_with_lambda);
+
+ public override Task Update_nested_associate_to_another_nested_associate()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_another_nested_associate);
+
+ public override Task Update_nested_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_parameter);
+
+ public override Task Update_nested_collection_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_inline_with_lambda);
+
+ public override Task Update_nested_collection_to_another_nested_collection()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_another_nested_collection);
+
+ public override Task Update_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_collection_to_parameter);
+
+ public override Task Update_collection_referencing_the_original_collection()
+ => Assert.ThrowsAsync(base.Update_collection_referencing_the_original_collection);
+
+ public override Task Update_primitive_collection_to_another_collection()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_another_collection);
+
+ public override Task Update_inside_structural_collection()
+ => Assert.ThrowsAsync(base.Update_inside_structural_collection);
+
+ public override Task Update_multiple_properties_inside_associates_and_on_entity_type()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_associates_and_on_entity_type);
+
+ public override Task Update_multiple_projected_associates_via_anonymous_type()
+ => Assert.ThrowsAsync(base.Update_multiple_projected_associates_via_anonymous_type);
+
+ public override async Task Update_property_inside_nested_associate()
+ {
+ await base.Update_property_inside_nested_associate();
+
+ AssertExecuteUpdateSql(
+ """
+@p='foo_updated' (Size = 255)
+
+UPDATE `RootEntity` AS `r`
+INNER JOIN `AssociateType` AS `a` ON `r`.`RequiredAssociateId` = `a`.`Id`
+INNER JOIN `NestedAssociateType` AS `n` ON `a`.`RequiredNestedAssociateId` = `n`.`Id`
+SET `n`.`String` = @p
+""");
+ }
+
+ public override async Task Update_associate_with_null_required_property()
+ {
+ await base.Update_associate_with_null_required_property();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_required_nested_associate_to_null()
+ {
+ await base.Update_required_nested_associate_to_null();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_inside_primitive_collection()
+ {
+ await base.Update_inside_primitive_collection();
+
+ AssertExecuteUpdateSql(
+ """
+@p='99'
+
+SET NOCOUNT OFF;
+UPDATE [a0]
+SET [a0].[Ints] = JSON_MODIFY([a0].[Ints], '$[1]', @p)
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [AssociateType] AS [a0] ON [r].[RequiredAssociateId] = [a0].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) >= 2
+""");
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..fca96458
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,181 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsPrimitiveCollectionLibRedTest(NavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE CAST(JSON_VALUE([a].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [NestedAssociateType] AS [n] ON [a].[RequiredNestedAssociateId] = [n].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[OptionalNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a0].[RequiredNestedAssociateId] = [n1].[Id]
+LEFT JOIN [NestedAssociateType] AS [n2] ON [a].[OptionalNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([n].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..d0d3ccde
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,181 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Associations.OwnedNavigations;
+
+public class OwnedNavigationsPrimitiveCollectionLibRedTest(OwnedNavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : OwnedNavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r0].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r0].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r1].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..eb7c7174
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,152 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Associations.OwnedTableSplitting;
+
+public class OwnedTableSplittingPrimitiveCollectionLibRedTest(
+ OwnedTableSplittingLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : OwnedTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r2].[AssociateTypeRootEntityId], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r0].[RootEntityId], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r1].[AssociateTypeRootEntityId], [r1].[AssociateTypeId], [r1].[Id] AS [Id0], [r1].[Int] AS [Int0], [r1].[Ints] AS [Ints0], [r1].[Name] AS [Name0], [r1].[String] AS [String0], [r0].[OptionalNestedAssociate_Id], [r0].[OptionalNestedAssociate_Int], [r0].[OptionalNestedAssociate_Ints], [r0].[OptionalNestedAssociate_Name], [r0].[OptionalNestedAssociate_String], [r0].[RequiredNestedAssociate_Id], [r0].[RequiredNestedAssociate_Int], [r0].[RequiredNestedAssociate_Ints], [r0].[RequiredNestedAssociate_Name], [r0].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r0]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId] AND [r0].[Id] = [r1].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r2] ON [r].[Id] = [r2].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r2].[AssociateTypeRootEntityId], [r2].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..a856cb33
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryLibRedFixture : TPCInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..b10da1aa
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,181 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryLibRedTest(TPCInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType`
+FROM `Coke` AS `c`
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `u`.`ParentComplexType`
+FROM (
+ SELECT `d`.`ParentComplexType`
+ FROM `Drinks` AS `d`
+ UNION ALL
+ SELECT `c`.`ParentComplexType`
+ FROM `Coke` AS `c`
+ UNION ALL
+ SELECT `l`.`ParentComplexType`
+ FROM `Lilt` AS `l`
+ UNION ALL
+ SELECT `t`.`ParentComplexType`
+ FROM `Tea` AS `t`
+) AS `u`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([u].[ParentComplexType], '$.Nested')
+FROM (
+ SELECT [d].[ParentComplexType]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[ParentComplexType]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[ParentComplexType]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[ParentComplexType]
+ FROM [Tea] AS [t]
+) AS [u]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..4b6dfe40
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,175 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceTableSplittingQueryLibRedTest(TPCInheritanceQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`Id`, `c`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `c`.`ComplexTypeCollection`, `c`.`Int`, `c`.`UniqueInt`, `c`.`NestedInt`, `c`.`NestedComplexType_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+WHERE `c`.`ChildComplexType_Int` = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `u`.`Id`, `u`.`SortIndex`, `u`.`CaffeineGrams`, `u`.`CokeCO2`, `u`.`Ints`, `u`.`SugarGrams`, `u`.`LiltCO2`, `u`.`SugarGrams1`, `u`.`CaffeineGrams1`, `u`.`HasMilk`, `u`.`ComplexTypeCollection`, `u`.`ParentComplexType_Int`, `u`.`ParentComplexType_UniqueInt`, `u`.`ParentComplexType_Nested_NestedInt`, `u`.`ParentComplexType_Nested_UniqueInt`, `u`.`ChildComplexType_Int`, `u`.`ChildComplexType_UniqueInt`, `u`.`ChildComplexType_Nested_NestedInt`, `u`.`ChildComplexType_Nested_UniqueInt`, `u`.`ChildComplexType_Int1`, `u`.`ChildComplexType_UniqueInt1`, `u`.`ChildComplexType_Nested_NestedInt1`, `u`.`ChildComplexType_Nested_UniqueInt1`, `u`.`Discriminator`
+FROM (
+ SELECT `d`.`Id`, `d`.`SortIndex`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Drink' AS `Discriminator`
+ FROM `Drinks` AS `d`
+ UNION ALL
+ SELECT `c`.`Id`, `c`.`SortIndex`, `c`.`ComplexTypeCollection`, `c`.`Int` AS `ParentComplexType_Int`, `c`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `c`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `c`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Coke' AS `Discriminator`
+ FROM `Coke` AS `c`
+ UNION ALL
+ SELECT `l`.`Id`, `l`.`SortIndex`, `l`.`ComplexTypeCollection`, `l`.`Int` AS `ParentComplexType_Int`, `l`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `l`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `l`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, `l`.`LiltCO2`, `l`.`SugarGrams` AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Lilt' AS `Discriminator`
+ FROM `Lilt` AS `l`
+ UNION ALL
+ SELECT `t`.`Id`, `t`.`SortIndex`, `t`.`ComplexTypeCollection`, `t`.`Int` AS `ParentComplexType_Int`, `t`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `t`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `t`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, `t`.`CaffeineGrams` AS `CaffeineGrams1`, `t`.`HasMilk`, `t`.`ChildComplexType_Int` AS `ChildComplexType_Int1`, `t`.`ChildComplexType_UniqueInt` AS `ChildComplexType_UniqueInt1`, `t`.`ChildComplexType_Nested_NestedInt` AS `ChildComplexType_Nested_NestedInt1`, `t`.`ChildComplexType_Nested_UniqueInt` AS `ChildComplexType_Nested_UniqueInt1`, 'Tea' AS `Discriminator`
+ FROM `Tea` AS `t`
+) AS `u`
+WHERE `u`.`ParentComplexType_Int` = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`Id`, `c`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `c`.`ComplexTypeCollection`, `c`.`Int`, `c`.`UniqueInt`, `c`.`NestedInt`, `c`.`NestedComplexType_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+WHERE `c`.`ChildComplexType_Nested_NestedInt` = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `u`.`Id`, `u`.`SortIndex`, `u`.`CaffeineGrams`, `u`.`CokeCO2`, `u`.`Ints`, `u`.`SugarGrams`, `u`.`LiltCO2`, `u`.`SugarGrams1`, `u`.`CaffeineGrams1`, `u`.`HasMilk`, `u`.`ComplexTypeCollection`, `u`.`ParentComplexType_Int`, `u`.`ParentComplexType_UniqueInt`, `u`.`ParentComplexType_Nested_NestedInt`, `u`.`ParentComplexType_Nested_UniqueInt`, `u`.`ChildComplexType_Int`, `u`.`ChildComplexType_UniqueInt`, `u`.`ChildComplexType_Nested_NestedInt`, `u`.`ChildComplexType_Nested_UniqueInt`, `u`.`ChildComplexType_Int1`, `u`.`ChildComplexType_UniqueInt1`, `u`.`ChildComplexType_Nested_NestedInt1`, `u`.`ChildComplexType_Nested_UniqueInt1`, `u`.`Discriminator`
+FROM (
+ SELECT `d`.`Id`, `d`.`SortIndex`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Drink' AS `Discriminator`
+ FROM `Drinks` AS `d`
+ UNION ALL
+ SELECT `c`.`Id`, `c`.`SortIndex`, `c`.`ComplexTypeCollection`, `c`.`Int` AS `ParentComplexType_Int`, `c`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `c`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `c`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Coke' AS `Discriminator`
+ FROM `Coke` AS `c`
+ UNION ALL
+ SELECT `l`.`Id`, `l`.`SortIndex`, `l`.`ComplexTypeCollection`, `l`.`Int` AS `ParentComplexType_Int`, `l`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `l`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `l`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, `l`.`LiltCO2`, `l`.`SugarGrams` AS `SugarGrams1`, NULL AS `CaffeineGrams1`, NULL AS `HasMilk`, NULL AS `ChildComplexType_Int1`, NULL AS `ChildComplexType_UniqueInt1`, NULL AS `ChildComplexType_Nested_NestedInt1`, NULL AS `ChildComplexType_Nested_UniqueInt1`, 'Lilt' AS `Discriminator`
+ FROM `Lilt` AS `l`
+ UNION ALL
+ SELECT `t`.`Id`, `t`.`SortIndex`, `t`.`ComplexTypeCollection`, `t`.`Int` AS `ParentComplexType_Int`, `t`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `t`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `t`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`, NULL AS `CaffeineGrams`, NULL AS `CokeCO2`, NULL AS `Ints`, NULL AS `SugarGrams`, NULL AS `ChildComplexType_Int`, NULL AS `ChildComplexType_UniqueInt`, NULL AS `ChildComplexType_Nested_NestedInt`, NULL AS `ChildComplexType_Nested_UniqueInt`, NULL AS `LiltCO2`, NULL AS `SugarGrams1`, `t`.`CaffeineGrams` AS `CaffeineGrams1`, `t`.`HasMilk`, `t`.`ChildComplexType_Int` AS `ChildComplexType_Int1`, `t`.`ChildComplexType_UniqueInt` AS `ChildComplexType_UniqueInt1`, `t`.`ChildComplexType_Nested_NestedInt` AS `ChildComplexType_Nested_NestedInt1`, `t`.`ChildComplexType_Nested_UniqueInt` AS `ChildComplexType_Nested_UniqueInt1`, 'Tea' AS `Discriminator`
+ FROM `Tea` AS `t`
+) AS `u`
+WHERE `u`.`ParentComplexType_Nested_NestedInt` = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+UNION ALL
+SELECT `c`.`Int` AS `ParentComplexType_Int`, `c`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `c`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `c`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+UNION ALL
+SELECT `l`.`Int` AS `ParentComplexType_Int`, `l`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `l`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `l`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Lilt` AS `l`
+UNION ALL
+SELECT `t`.`Int` AS `ParentComplexType_Int`, `t`.`UniqueInt` AS `ParentComplexType_UniqueInt`, `t`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `t`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Tea` AS `t`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+UNION ALL
+SELECT `c`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `c`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Coke` AS `c`
+UNION ALL
+SELECT `l`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `l`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Lilt` AS `l`
+UNION ALL
+SELECT `t`.`NestedInt` AS `ParentComplexType_Nested_NestedInt`, `t`.`NestedComplexType_UniqueInt` AS `ParentComplexType_Nested_UniqueInt`
+FROM `Tea` AS `t`
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..e6509b0b
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryLibRedFixture : TPHInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..d067147e
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,122 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryLibRedTest(TPHInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPHInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ChildComplexType`
+FROM `Drinks` AS `d`
+WHERE `d`.`Discriminator` = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..3efa7383
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,125 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceTableSplittingQueryLibRedTest(
+ TPHInheritanceQueryLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPHInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`Discriminator`, `d`.`SortIndex`, `d`.`CaffeineGrams`, `d`.`CokeCO2`, `d`.`Ints`, `d`.`SugarGrams`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `d`.`ChildComplexType_Int`, `d`.`ChildComplexType_UniqueInt`, `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`Discriminator` = 1 AND `d`.`ChildComplexType_Int` = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`Discriminator`, `d`.`SortIndex`, `d`.`CaffeineGrams`, `d`.`CokeCO2`, `d`.`Ints`, `d`.`SugarGrams`, `d`.`LiltCO2`, `d`.`HasMilk`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `d`.`ChildComplexType_Int`, `d`.`ChildComplexType_UniqueInt`, `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`, `d`.`Tea_ChildComplexType_Int`, `d`.`Tea_ChildComplexType_UniqueInt`, `d`.`Tea_ChildComplexType_Nested_NestedInt`, `d`.`Tea_ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`ParentComplexType_Int` = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`Discriminator`, `d`.`SortIndex`, `d`.`CaffeineGrams`, `d`.`CokeCO2`, `d`.`Ints`, `d`.`SugarGrams`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `d`.`ChildComplexType_Int`, `d`.`ChildComplexType_UniqueInt`, `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`Discriminator` = 1 AND `d`.`ChildComplexType_Nested_NestedInt` = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`Discriminator`, `d`.`SortIndex`, `d`.`CaffeineGrams`, `d`.`CokeCO2`, `d`.`Ints`, `d`.`SugarGrams`, `d`.`LiltCO2`, `d`.`HasMilk`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `d`.`ChildComplexType_Int`, `d`.`ChildComplexType_UniqueInt`, `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`, `d`.`Tea_ChildComplexType_Int`, `d`.`Tea_ChildComplexType_UniqueInt`, `d`.`Tea_ChildComplexType_Nested_NestedInt`, `d`.`Tea_ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`ParentComplexType_Nested_NestedInt` = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ChildComplexType_Int`, `d`.`ChildComplexType_UniqueInt`, `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`Discriminator` = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ChildComplexType_Nested_NestedInt`, `d`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+WHERE `d`.`Discriminator` = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..2c2f057b
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryLibRedFixture : TPTInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..b019b594
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,145 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryLibRedTest(TPTInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPTInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType`
+FROM `Drinks` AS `d`
+INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..4017b3ab
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,148 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceTableSplittingQueryLibRedTest(
+ TPTInheritanceQueryLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPTInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+WHERE `c`.`ChildComplexType_Int` = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `l`.`LiltCO2`, `l`.`SugarGrams`, `t`.`CaffeineGrams`, `t`.`HasMilk`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`, `t`.`ChildComplexType_Int`, `t`.`ChildComplexType_UniqueInt`, `t`.`ChildComplexType_Nested_NestedInt`, `t`.`ChildComplexType_Nested_UniqueInt`, CASE
+ WHEN `t`.`Id` IS NOT NULL THEN 'Tea'
+ WHEN `l`.`Id` IS NOT NULL THEN 'Lilt'
+ WHEN `c`.`Id` IS NOT NULL THEN 'Coke'
+END AS `Discriminator`
+FROM `Drinks` AS `d`
+LEFT JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+LEFT JOIN `Lilt` AS `l` ON `d`.`Id` = `l`.`Id`
+LEFT JOIN `Tea` AS `t` ON `d`.`Id` = `t`.`Id`
+WHERE `d`.`ParentComplexType_Int` = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+WHERE `c`.`ChildComplexType_Nested_NestedInt` = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`Id`, `d`.`SortIndex`, `c`.`CaffeineGrams`, `c`.`CokeCO2`, `c`.`Ints`, `c`.`SugarGrams`, `l`.`LiltCO2`, `l`.`SugarGrams`, `t`.`CaffeineGrams`, `t`.`HasMilk`, `d`.`ComplexTypeCollection`, `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`, `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`, `t`.`ChildComplexType_Int`, `t`.`ChildComplexType_UniqueInt`, `t`.`ChildComplexType_Nested_NestedInt`, `t`.`ChildComplexType_Nested_UniqueInt`, CASE
+ WHEN `t`.`Id` IS NOT NULL THEN 'Tea'
+ WHEN `l`.`Id` IS NOT NULL THEN 'Lilt'
+ WHEN `c`.`Id` IS NOT NULL THEN 'Coke'
+END AS `Discriminator`
+FROM `Drinks` AS `d`
+LEFT JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+LEFT JOIN `Lilt` AS `l` ON `d`.`Id` = `l`.`Id`
+LEFT JOIN `Tea` AS `t` ON `d`.`Id` = `t`.`Id`
+WHERE `d`.`ParentComplexType_Nested_NestedInt` = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType_Int`, `c`.`ChildComplexType_UniqueInt`, `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Int`, `d`.`ParentComplexType_UniqueInt`, `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT `c`.`ChildComplexType_Nested_NestedInt`, `c`.`ChildComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id`
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT `d`.`ParentComplexType_Nested_NestedInt`, `d`.`ParentComplexType_Nested_UniqueInt`
+FROM `Drinks` AS `d`
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs
new file mode 100644
index 00000000..647c6fe1
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs
@@ -0,0 +1,70 @@
+using System.Threading.Tasks;
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Translations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Query.Translations;
+
+public class JsonTranslationsLibRedTest : JsonTranslationsRelationalTestBase<
+ JsonTranslationsLibRedTest.JsonTranslationsQueryLibRedFixture>
+{
+ public JsonTranslationsLibRedTest(JsonTranslationsQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : base(fixture)
+ {
+ Fixture.TestSqlLoggerFactory.Clear();
+ Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
+ }
+
+ public override async Task JsonPathExists_on_scalar_string_column()
+ {
+ await base.JsonPathExists_on_scalar_string_column();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonString], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_complex_property()
+ {
+ await base.JsonPathExists_on_complex_property();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonComplexType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_owned_entity()
+ {
+ await base.JsonPathExists_on_owned_entity();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonOwnedType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public class JsonTranslationsQueryLibRedFixture : JsonTranslationsQueryFixtureBase, ITestSqlLoggerFactory
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+
+ protected override string RemoveJsonProperty(string column, string property)
+ => $"JSON_MODIFY({column}, '$.{property}', NULL)";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ private void AssertSql(params string[] expected)
+ => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/RuntimeMigrationLibRedTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/RuntimeMigrationLibRedTest.cs
new file mode 100644
index 00000000..0586fffe
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/RuntimeMigrationLibRedTest.cs
@@ -0,0 +1,20 @@
+using System.Reflection;
+using EntityFrameworkCore.LibRed.Design.Internal;
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests;
+
+public class RuntimeMigrationLibRedTest(RuntimeMigrationLibRedTest.RuntimeMigrationLibRedFixture fixture)
+ : RuntimeMigrationTestBase(fixture)
+{
+ protected override Assembly ProviderAssembly
+ => typeof(LibRedDesignTimeServices).Assembly;
+
+ public class RuntimeMigrationLibRedFixture : RuntimeMigrationFixtureBase
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/LibRedTypeFixture.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/LibRedTypeFixture.cs
new file mode 100644
index 00000000..ffab697b
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/LibRedTypeFixture.cs
@@ -0,0 +1,14 @@
+using EntityFrameworkCore.LibRed.Extended.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types;
+
+public abstract class LibRedTypeFixture : RelationalTypeFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+
+ public virtual bool UsingJsonType
+ => false;
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs
new file mode 100644
index 00000000..29455462
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs
@@ -0,0 +1,234 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedBoolTypeTest(LibRedBoolTypeTest.BoolTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value`
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='True'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bit '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='False'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bit) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bit) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":false,"Value":false}' (Nullable = false) (Size = 34)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class BoolTypeFixture : LibRedTypeFixture
+ {
+ public override bool Value { get; } = true;
+ public override bool OtherValue { get; } = false;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs
new file mode 100644
index 00000000..b9237875
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs
@@ -0,0 +1,216 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedByteArrayTypeTest(LibRedByteArrayTypeTest.ByteArrayTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 510)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = 0x010203
+""");
+ }
+
+ // byte[].Equals() does reference equality, so the base test doesn't work for byte arrays
+ public override Task Primitive_collection_in_query()
+ => Task.CompletedTask;
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='0x04050607' (Size = 510)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with varbinary even on SQL Server 2025, as that type isn't supported
+ // (#36627).
+ // We also can't just wrap JSON_VALUE() with CAST(... AS varbinary(max)), as that would apply a SQL Server binary format
+ // conversion, and not base64. So we use OPENJSON which does perform base64 conversion.
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 8000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+OUTER APPLY OPENJSON([j].[JsonContainer]) WITH ([Value] varbinary(max) '$.Value') AS [v]
+WHERE [v].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"BAUGBw==","Value":"BAUGBw=="}' (Nullable = false) (Size = 44)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteArrayTypeFixture : LibRedTypeFixture
+ {
+ public override byte[] Value { get; } = [1, 2, 3];
+ public override byte[] OtherValue { get; } = [4, 5, 6, 7];
+
+ public override Func Comparer { get; } = (a, b) => a.SequenceEqual(b);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs
new file mode 100644
index 00000000..d0c2d883
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs
@@ -0,0 +1,223 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedGuidTypeTest(LibRedGuidTypeTest.GuidTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = {8f7331d6-cde9-44fb-8611-81fff686f280}
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] uniqueidentifier '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='ae192c36-9004-49b2-b785-8be10d169627'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with uniqueidentifier even on SQL Server 2025, as that type isn't
+ // supported (#36627).
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS uniqueidentifier) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"ae192c36-9004-49b2-b785-8be10d169627","Value":"ae192c36-9004-49b2-b785-8be10d169627"}' (Nullable = false) (Size = 100)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class GuidTypeFixture : LibRedTypeFixture
+ {
+ public override Guid Value { get; } = new("8f7331d6-cde9-44fb-8611-81fff686f280");
+ public override Guid OtherValue { get; } = new("ae192c36-9004-49b2-b785-8be10d169627");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs
new file mode 100644
index 00000000..588eeb5d
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs
@@ -0,0 +1,234 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedStringTypeTest(LibRedStringTypeTest.StringTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 255)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = 'foo'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='foo' (Size = 4000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] nvarchar(max) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='bar' (Size = 255)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING nvarchar(max)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value') = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"bar","Value":"bar"}' (Nullable = false) (Size = 34)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class StringTypeFixture : LibRedTypeFixture
+ {
+ public override string Value { get; } = "foo";
+ public override string OtherValue { get; } = "bar";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs
new file mode 100644
index 00000000..40424d85
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs
@@ -0,0 +1,234 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedByteTypeTest(LibRedByteTypeTest.ByteTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = CBYTE(0)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='0' (Size = 1)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] tinyint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='255' (Size = 1)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING tinyint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS tinyint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":255,"Value":255}' (Nullable = false) (Size = 30)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteTypeFixture : LibRedTypeFixture
+ {
+ public override byte Value { get; } = byte.MinValue;
+ public override byte OtherValue { get; } = byte.MaxValue;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs
new file mode 100644
index 00000000..7abc7262
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs
@@ -0,0 +1,233 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedDecimalTypeTest(LibRedDecimalTypeTest.DecimalTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 30.5
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] decimal(18,2) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30' (Precision = 18) (Scale = 2)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING decimal(18,2)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS decimal(18,2)) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DecimalTypeFixture : LibRedTypeFixture
+ {
+ public override decimal Value { get; } = 30.5m;
+ public override decimal OtherValue { get; } = 30m;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs
new file mode 100644
index 00000000..f4c98503
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs
@@ -0,0 +1,229 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedDoubleTypeTest(LibRedDoubleTypeTest.DoubleTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = 30.5
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] float '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING float) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS float) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DoubleTypeFixture : LibRedTypeFixture
+ {
+ public override double Value { get; } = 30.5d;
+ public override double OtherValue { get; } = 30d;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs
new file mode 100644
index 00000000..173ade0c
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs
@@ -0,0 +1,229 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedFloatTypeTest(LibRedFloatTypeTest.FloatTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = 30.5
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] real '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING real) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS real) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class FloatTypeFixture : LibRedTypeFixture
+ {
+ public override float Value { get; } = 30.5f;
+ public override float OtherValue { get; } = 30f;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs
new file mode 100644
index 00000000..c594fc78
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs
@@ -0,0 +1,229 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedIntTypeTest(LibRedIntTypeTest.IntTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = -2147483648
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-2147483648'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] int '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2147483647'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING int) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS int) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":2147483647,"Value":2147483647}' (Nullable = false) (Size = 44)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class IntTypeFixture : LibRedTypeFixture
+ {
+ public override int Value { get; } = int.MinValue;
+ public override int OtherValue { get; } = int.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs
new file mode 100644
index 00000000..b13160d7
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs
@@ -0,0 +1,229 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedLongTypeTest(LibRedLongTypeTest.LongTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = -9223372036854775808
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-9223372036854775808'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bigint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='9223372036854775807'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bigint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bigint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":9223372036854775807,"Value":9223372036854775807}' (Nullable = false) (Size = 62)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class LongTypeFixture : LibRedTypeFixture
+ {
+ public override long Value { get; } = long.MinValue;
+ public override long OtherValue { get; } = long.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs
new file mode 100644
index 00000000..b0428aae
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs
@@ -0,0 +1,229 @@
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Numeric;
+
+public class LibRedShortTypeTest(LibRedShortTypeTest.ShortTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = CINT(-32768)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-32768'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] smallint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='32767'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING smallint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS smallint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":32767,"Value":32767}' (Nullable = false) (Size = 34)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ShortTypeFixture : LibRedTypeFixture
+ {
+ public override short Value { get; } = short.MinValue;
+ public override short OtherValue { get; } = short.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs
new file mode 100644
index 00000000..e77c3bc0
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs
@@ -0,0 +1,235 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedDateOnlyTypeTest(LibRedDateOnlyTypeTest.DateTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T00:00:00.0000000' (DbType = Date)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = #2020-01-05#
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] date '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000' (DbType = Date)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING date) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS date) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03","Value":"2022-05-03"}' (Nullable = false) (Size = 48)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTypeFixture : LibRedTypeFixture
+ {
+ public override DateOnly Value { get; } = new(2020, 1, 5);
+ public override DateOnly OtherValue { get; } = new(2022, 5, 3);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs
new file mode 100644
index 00000000..ee9de9af
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs
@@ -0,0 +1,235 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTime2TypeTest(LibRedDateTime2TypeTest.DateTime2TypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = #2020-01-05 12:30:45#
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime2 '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000' (DbType = DateTime)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetime2) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime2) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTime2TypeFixture : LibRedTypeFixture
+ {
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs
new file mode 100644
index 00000000..7625ae0e
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs
@@ -0,0 +1,237 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTimeOffsetTypeTest(
+ LibRedDateTimeOffsetTypeTest.DateTimeOffsetTypeFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T10:30:45.0000000Z' (DbType = DateTime)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = CDATE('2020-01-05 10:30:45')
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetimeoffset '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2020-01-05T09:30:45.0000000Z' (DbType = DateTime)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetimeoffset) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetimeoffset) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2020-01-05T12:30:45+03:00","Value":"2020-01-05T12:30:45+03:00"}' (Nullable = false) (Size = 78)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeOffsetTypeFixture : LibRedTypeFixture
+ {
+ public override DateTimeOffset Value { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(2));
+ public override DateTimeOffset OtherValue { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(3));
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs
new file mode 100644
index 00000000..7174b88c
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs
@@ -0,0 +1,225 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTimeTypeTest(LibRedDateTimeTypeTest.DateTimeTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = #2020-01-05 12:30:45#
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000' (DbType = DateTime)
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeTypeFixture : LibRedTypeFixture
+ {
+ // The default mapping for .NET DateTime is datetime2; this tests the non-default (and discouraged) datetime type.
+ public override string StoreType
+ => "datetime";
+
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs
new file mode 100644
index 00000000..0770a58a
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs
@@ -0,0 +1,235 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedTimeOnlyTypeTest(LibRedTimeOnlyTypeTest.TimeOnlyTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = TIMEVALUE('12:30:45')
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='12:30' (DbType = Time)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] time '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='14:00:00'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING time) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS time) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"14:00:00.0000000","Value":"14:00:00.0000000"}' (Nullable = false) (Size = 60)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class TimeOnlyTypeFixture : LibRedTypeFixture
+ {
+ public override TimeOnly Value { get; } = new(12, 30, 45);
+ public override TimeOnly OtherValue { get; } = new(14, 0, 0);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs
new file mode 100644
index 00000000..1631bb2b
--- /dev/null
+++ b/test/EFCore.LibRed.Extended.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs
@@ -0,0 +1,235 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.Extended.FunctionalTests.Types.Temporal;
+
+public class LibRedTimeSpanTypeTest(LibRedTimeSpanTypeTest.TimeSpanTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP 2 `t`.`Id`, `t`.`ArrayValue`, `t`.`OtherValue`, `t`.`Value`
+FROM `TypeEntity` AS `t`
+WHERE `t`.`Value` = TIMEVALUE('12:30:45')
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='12:30:45'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] time '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='14:00:00'
+
+UPDATE `TypeEntity` SET `Value` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING time) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30:45'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS time) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"14:00:00","Value":"14:00:00"}' (Nullable = false) (Size = 44)
+@p1='1'
+
+UPDATE `JsonTypeEntity` SET `JsonContainer` = @p0
+WHERE `Id` = @p1;
+SELECT @@ROWCOUNT;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'14:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'14:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class TimeSpanTypeFixture : LibRedTypeFixture
+ {
+ public override TimeSpan Value { get; } = new(12, 30, 45);
+ public override TimeSpan OtherValue { get; } = new(14, 0, 0);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
index 782c2345..eb0b1dc4 100644
--- a/test/EFCore.LibRed.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
+++ b/test/EFCore.LibRed.FunctionalTests/Query/AdHocQueryFiltersQueryLibRedTest.cs
@@ -509,20 +509,6 @@ public override async Task Named_query_filters_combined()
AssertSql();
}
- public override async Task Query_filter_with_EF_Constant_throws()
- {
- await base.Query_filter_with_EF_Constant_throws();
-
- AssertSql();
- }
-
- public override async Task Query_filter_with_EF_Parameter_throws()
- {
- await base.Query_filter_with_EF_Parameter_throws();
-
- AssertSql();
- }
-
public override async Task GroupBy_aggregate_over_required_navigation_with_query_filter(bool async)
{
await base.GroupBy_aggregate_over_required_navigation_with_query_filter(async);
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..02d7cf57
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,102 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Associations.ComplexTableSplitting;
+
+public class ComplexTableSplittingPrimitiveCollectionLibRedTest(
+ ComplexTableSplittingLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : ComplexTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs
new file mode 100644
index 00000000..40fb22ff
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsBulkUpdateLibRedTest.cs
@@ -0,0 +1,158 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System;
+using System.Data.Common;
+using System.Threading.Tasks;
+using Xunit;
+using Xunit.Sdk;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsBulkUpdateLibRedTest(NavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsBulkUpdateRelationalTestBase(fixture, testOutputHelper)
+{
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ // FK constraint failures
+ public override Task Delete_entity_with_associations()
+ => Assert.ThrowsAsync(base.Delete_entity_with_associations);
+
+ public override Task Delete_required_associate()
+ => Assert.ThrowsAsync(base.Delete_required_associate);
+
+ // SQL generation produces invalid object name for these scenarios
+ public override Task Delete_optional_associate()
+ => Assert.ThrowsAsync(base.Delete_optional_associate);
+
+ public override Task Update_property_inside_associate()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate);
+
+ public override Task Update_property_inside_associate_with_special_chars()
+ => Assert.ThrowsAsync(base.Update_property_inside_associate_with_special_chars);
+
+ public override Task Update_property_on_projected_associate()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate);
+
+ public override Task Update_property_on_projected_associate_with_OrderBy_Skip()
+ => Assert.ThrowsAsync(base.Update_property_on_projected_associate_with_OrderBy_Skip);
+
+ public override Task Update_multiple_properties_inside_same_associate()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_same_associate);
+
+ public override Task Update_primitive_collection_to_constant()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_constant);
+
+ public override Task Update_primitive_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_parameter);
+
+ // Translation not yet supported for navigation-mapped associations
+ public override Task Update_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_parameter);
+
+ public override Task Update_associate_to_inline()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline);
+
+ public override Task Update_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_inline_with_lambda);
+
+ public override Task Update_associate_to_another_associate()
+ => Assert.ThrowsAsync(base.Update_associate_to_another_associate);
+
+ public override Task Update_associate_to_null()
+ => Assert.ThrowsAsync(base.Update_associate_to_null);
+
+ public override Task Update_associate_to_null_with_lambda()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_with_lambda);
+
+ public override Task Update_associate_to_null_parameter()
+ => Assert.ThrowsAsync(base.Update_associate_to_null_parameter);
+
+ public override Task Update_nested_associate_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_parameter);
+
+ public override Task Update_nested_associate_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_inline_with_lambda);
+
+ public override Task Update_nested_associate_to_another_nested_associate()
+ => Assert.ThrowsAsync(base.Update_nested_associate_to_another_nested_associate);
+
+ public override Task Update_nested_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_parameter);
+
+ public override Task Update_nested_collection_to_inline_with_lambda()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_inline_with_lambda);
+
+ public override Task Update_nested_collection_to_another_nested_collection()
+ => Assert.ThrowsAsync(base.Update_nested_collection_to_another_nested_collection);
+
+ public override Task Update_collection_to_parameter()
+ => Assert.ThrowsAsync(base.Update_collection_to_parameter);
+
+ public override Task Update_collection_referencing_the_original_collection()
+ => Assert.ThrowsAsync(base.Update_collection_referencing_the_original_collection);
+
+ public override Task Update_primitive_collection_to_another_collection()
+ => Assert.ThrowsAsync(base.Update_primitive_collection_to_another_collection);
+
+ public override Task Update_inside_structural_collection()
+ => Assert.ThrowsAsync(base.Update_inside_structural_collection);
+
+ public override Task Update_multiple_properties_inside_associates_and_on_entity_type()
+ => Assert.ThrowsAsync(base.Update_multiple_properties_inside_associates_and_on_entity_type);
+
+ public override Task Update_multiple_projected_associates_via_anonymous_type()
+ => Assert.ThrowsAsync(base.Update_multiple_projected_associates_via_anonymous_type);
+
+ public override async Task Update_property_inside_nested_associate()
+ {
+ await base.Update_property_inside_nested_associate();
+
+ AssertExecuteUpdateSql(
+ """
+@p='foo_updated' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [n]
+SET [n].[String] = @p
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [NestedAssociateType] AS [n] ON [a].[RequiredNestedAssociateId] = [n].[Id]
+""");
+ }
+
+ public override async Task Update_associate_with_null_required_property()
+ {
+ await base.Update_associate_with_null_required_property();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_required_nested_associate_to_null()
+ {
+ await base.Update_required_nested_associate_to_null();
+
+ AssertExecuteUpdateSql();
+ }
+
+ public override async Task Update_inside_primitive_collection()
+ {
+ await base.Update_inside_primitive_collection();
+
+ AssertExecuteUpdateSql(
+ """
+@p='99'
+
+SET NOCOUNT OFF;
+UPDATE [a0]
+SET [a0].[Ints] = JSON_MODIFY([a0].[Ints], '$[1]', @p)
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [AssociateType] AS [a0] ON [r].[RequiredAssociateId] = [a0].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) >= 2
+""");
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..681069c7
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Associations.Navigations;
+
+public class NavigationsPrimitiveCollectionLibRedTest(NavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : NavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([a].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE CAST(JSON_VALUE([a].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n] ON [a0].[OptionalNestedAssociateId] = [n].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[RequiredNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a].[OptionalNestedAssociateId] = [n1].[Id]
+INNER JOIN [NestedAssociateType] AS [n2] ON [a].[RequiredNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r].[OptionalAssociateId], [r].[RequiredAssociateId], [s].[Id], [s].[CollectionRootId], [s].[Int], [s].[Ints], [s].[Name], [s].[OptionalNestedAssociateId], [s].[RequiredNestedAssociateId], [s].[String], [s].[Id0], [s].[CollectionAssociateId], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[CollectionAssociateId0], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[CollectionAssociateId1], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [a0].[Id], [a0].[CollectionRootId], [a0].[Int], [a0].[Ints], [a0].[Name], [a0].[OptionalNestedAssociateId], [a0].[RequiredNestedAssociateId], [a0].[String], [n6].[Id], [n6].[CollectionAssociateId], [n6].[Int], [n6].[Ints], [n6].[Name], [n6].[String], [n0].[Id], [n0].[CollectionAssociateId], [n0].[Int], [n0].[Ints], [n0].[Name], [n0].[String], [n1].[Id], [n1].[CollectionAssociateId], [n1].[Int], [n1].[Ints], [n1].[Name], [n1].[String], [a].[Id], [a].[CollectionRootId], [a].[Int], [a].[Ints], [a].[Name], [a].[OptionalNestedAssociateId], [a].[RequiredNestedAssociateId], [a].[String], [n7].[Id], [n7].[CollectionAssociateId], [n7].[Int], [n7].[Ints], [n7].[Name], [n7].[String], [n2].[Id], [n2].[CollectionAssociateId], [n2].[Int], [n2].[Ints], [n2].[Name], [n2].[String], [n].[Id], [n].[CollectionAssociateId], [n].[Int], [n].[Ints], [n].[Name], [n].[String]
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+INNER JOIN [NestedAssociateType] AS [n] ON [a].[RequiredNestedAssociateId] = [n].[Id]
+LEFT JOIN [AssociateType] AS [a0] ON [r].[OptionalAssociateId] = [a0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n0] ON [a0].[OptionalNestedAssociateId] = [n0].[Id]
+LEFT JOIN [NestedAssociateType] AS [n1] ON [a0].[RequiredNestedAssociateId] = [n1].[Id]
+LEFT JOIN [NestedAssociateType] AS [n2] ON [a].[OptionalNestedAssociateId] = [n2].[Id]
+LEFT JOIN (
+ SELECT [a1].[Id], [a1].[CollectionRootId], [a1].[Int], [a1].[Ints], [a1].[Name], [a1].[OptionalNestedAssociateId], [a1].[RequiredNestedAssociateId], [a1].[String], [n5].[Id] AS [Id0], [n5].[CollectionAssociateId], [n5].[Int] AS [Int0], [n5].[Ints] AS [Ints0], [n5].[Name] AS [Name0], [n5].[String] AS [String0], [n3].[Id] AS [Id1], [n3].[CollectionAssociateId] AS [CollectionAssociateId0], [n3].[Int] AS [Int1], [n3].[Ints] AS [Ints1], [n3].[Name] AS [Name1], [n3].[String] AS [String1], [n4].[Id] AS [Id2], [n4].[CollectionAssociateId] AS [CollectionAssociateId1], [n4].[Int] AS [Int2], [n4].[Ints] AS [Ints2], [n4].[Name] AS [Name2], [n4].[String] AS [String2]
+ FROM [AssociateType] AS [a1]
+ LEFT JOIN [NestedAssociateType] AS [n3] ON [a1].[OptionalNestedAssociateId] = [n3].[Id]
+ INNER JOIN [NestedAssociateType] AS [n4] ON [a1].[RequiredNestedAssociateId] = [n4].[Id]
+ LEFT JOIN [NestedAssociateType] AS [n5] ON [a1].[Id] = [n5].[CollectionAssociateId]
+) AS [s] ON [r].[Id] = [s].[CollectionRootId]
+LEFT JOIN [NestedAssociateType] AS [n6] ON [a0].[Id] = [n6].[CollectionAssociateId]
+LEFT JOIN [NestedAssociateType] AS [n7] ON [a].[Id] = [n7].[CollectionAssociateId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([n].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [s].[Id], [s].[Id0], [n6].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+INNER JOIN [AssociateType] AS [a] ON [r].[RequiredAssociateId] = [a].[Id]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([a].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..3f2c5201
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Associations.OwnedNavigations;
+
+public class OwnedNavigationsPrimitiveCollectionLibRedTest(OwnedNavigationsLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : OwnedNavigationsPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r0].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r0].[Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [i].[value]
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]
+)
+ORDER BY [r].[Id], [r0].[RootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[Id1], [s].[Int1], [s].[Ints1], [s].[Name1], [s].[String1], [s].[Id2], [s].[Int2], [s].[Ints2], [s].[Name2], [s].[String2], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [o2].[AssociateTypeRootEntityId], [o2].[Id], [o2].[Int], [o2].[Ints], [o2].[Name], [o2].[String], [o0].[Id], [o0].[Int], [o0].[Ints], [o0].[Name], [o0].[String], [o1].[Id], [o1].[Int], [o1].[Ints], [o1].[Name], [o1].[String], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r7].[AssociateTypeRootEntityId], [r7].[Id], [r7].[Int], [r7].[Ints], [r7].[Name], [r7].[String], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String]
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+LEFT JOIN [RequiredRelated_RequiredNested] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated] AS [o] ON [r].[Id] = [o].[RootEntityId]
+LEFT JOIN [OptionalRelated_OptionalNested] AS [o0] ON [o].[RootEntityId] = [o0].[AssociateTypeRootEntityId]
+LEFT JOIN [OptionalRelated_RequiredNested] AS [o1] ON [o].[RootEntityId] = [o1].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_OptionalNested] AS [r2] ON [r0].[RootEntityId] = [r2].[AssociateTypeRootEntityId]
+LEFT JOIN (
+ SELECT [r3].[RootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r4].[AssociateTypeRootEntityId], [r4].[AssociateTypeId], [r5].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId0], [r5].[AssociateTypeId] AS [AssociateTypeId0], [r6].[AssociateTypeRootEntityId] AS [AssociateTypeRootEntityId1], [r6].[AssociateTypeId] AS [AssociateTypeId1], [r6].[Id] AS [Id0], [r6].[Int] AS [Int0], [r6].[Ints] AS [Ints0], [r6].[Name] AS [Name0], [r6].[String] AS [String0], [r4].[Id] AS [Id1], [r4].[Int] AS [Int1], [r4].[Ints] AS [Ints1], [r4].[Name] AS [Name1], [r4].[String] AS [String1], [r5].[Id] AS [Id2], [r5].[Int] AS [Int2], [r5].[Ints] AS [Ints2], [r5].[Name] AS [Name2], [r5].[String] AS [String2]
+ FROM [RelatedCollection] AS [r3]
+ LEFT JOIN [RelatedCollection_OptionalNested] AS [r4] ON [r3].[RootEntityId] = [r4].[AssociateTypeRootEntityId] AND [r3].[Id] = [r4].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_RequiredNested] AS [r5] ON [r3].[RootEntityId] = [r5].[AssociateTypeRootEntityId] AND [r3].[Id] = [r5].[AssociateTypeId]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r6] ON [r3].[RootEntityId] = [r6].[AssociateTypeRootEntityId] AND [r3].[Id] = [r6].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o2] ON [o].[RootEntityId] = [o2].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r7] ON [r0].[RootEntityId] = [r7].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r1].[Ints]) AS [i]) = 3
+ORDER BY [r].[Id], [r0].[RootEntityId], [r1].[AssociateTypeRootEntityId], [o].[RootEntityId], [o0].[AssociateTypeRootEntityId], [o1].[AssociateTypeRootEntityId], [r2].[AssociateTypeRootEntityId], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[AssociateTypeRootEntityId0], [s].[AssociateTypeId0], [s].[AssociateTypeRootEntityId1], [s].[AssociateTypeId1], [s].[Id0], [o2].[AssociateTypeRootEntityId], [o2].[Id], [r7].[AssociateTypeRootEntityId], [r7].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([i0].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i0])
+FROM [RootEntity] AS [r]
+LEFT JOIN [RequiredRelated] AS [r0] ON [r].[Id] = [r0].[RootEntityId]
+WHERE (
+ SELECT ISNULL(SUM([i].[value]), 0)
+ FROM OPENJSON([r0].[Ints]) WITH ([value] int '$') AS [i]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs
new file mode 100644
index 00000000..7636c3a1
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingPrimitiveCollectionLibRedTest.cs
@@ -0,0 +1,152 @@
+using Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Associations.OwnedTableSplitting;
+
+public class OwnedTableSplittingPrimitiveCollectionLibRedTest(
+ OwnedTableSplittingLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : OwnedTableSplittingPrimitiveCollectionRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Count()
+ {
+ await base.Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Index()
+ {
+ await base.Index();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r2].[AssociateTypeRootEntityId], [r2].[Id], [r2].[Int], [r2].[Ints], [r2].[Name], [r2].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r0].[RootEntityId], [r0].[Id], [r0].[Int], [r0].[Ints], [r0].[Name], [r0].[String], [r1].[AssociateTypeRootEntityId], [r1].[AssociateTypeId], [r1].[Id] AS [Id0], [r1].[Int] AS [Int0], [r1].[Ints] AS [Ints0], [r1].[Name] AS [Name0], [r1].[String] AS [String0], [r0].[OptionalNestedAssociate_Id], [r0].[OptionalNestedAssociate_Int], [r0].[OptionalNestedAssociate_Ints], [r0].[OptionalNestedAssociate_Name], [r0].[OptionalNestedAssociate_String], [r0].[RequiredNestedAssociate_Id], [r0].[RequiredNestedAssociate_Int], [r0].[RequiredNestedAssociate_Ints], [r0].[RequiredNestedAssociate_Name], [r0].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r0]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r1] ON [r0].[RootEntityId] = [r1].[AssociateTypeRootEntityId] AND [r0].[Id] = [r1].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r2] ON [r].[Id] = [r2].[AssociateTypeRootEntityId]
+WHERE CAST(JSON_VALUE([r].[RequiredAssociate_Ints], '$[0]') AS int) = 1
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r2].[AssociateTypeRootEntityId], [r2].[Id]
+""");
+ }
+
+ public override async Task Contains()
+ {
+ await base.Contains();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 3 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Any_predicate()
+ {
+ await base.Any_predicate();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE 2 IN (
+ SELECT [r0].[value]
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]
+)
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Nested_Count()
+ {
+ await base.Nested_Count();
+
+ AssertSql(
+ """
+SELECT [r].[Id], [r].[Name], [s].[RootEntityId], [s].[Id], [s].[Int], [s].[Ints], [s].[Name], [s].[String], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [s].[Int0], [s].[Ints0], [s].[Name0], [s].[String0], [s].[OptionalNestedAssociate_Id], [s].[OptionalNestedAssociate_Int], [s].[OptionalNestedAssociate_Ints], [s].[OptionalNestedAssociate_Name], [s].[OptionalNestedAssociate_String], [s].[RequiredNestedAssociate_Id], [s].[RequiredNestedAssociate_Int], [s].[RequiredNestedAssociate_Ints], [s].[RequiredNestedAssociate_Name], [s].[RequiredNestedAssociate_String], [r].[OptionalAssociate_Id], [r].[OptionalAssociate_Int], [r].[OptionalAssociate_Ints], [r].[OptionalAssociate_Name], [r].[OptionalAssociate_String], [o].[AssociateTypeRootEntityId], [o].[Id], [o].[Int], [o].[Ints], [o].[Name], [o].[String], [r].[OptionalAssociate_OptionalNestedAssociate_Id], [r].[OptionalAssociate_OptionalNestedAssociate_Int], [r].[OptionalAssociate_OptionalNestedAssociate_Ints], [r].[OptionalAssociate_OptionalNestedAssociate_Name], [r].[OptionalAssociate_OptionalNestedAssociate_String], [r].[OptionalAssociate_RequiredNestedAssociate_Id], [r].[OptionalAssociate_RequiredNestedAssociate_Int], [r].[OptionalAssociate_RequiredNestedAssociate_Ints], [r].[OptionalAssociate_RequiredNestedAssociate_Name], [r].[OptionalAssociate_RequiredNestedAssociate_String], [r].[RequiredAssociate_Id], [r].[RequiredAssociate_Int], [r].[RequiredAssociate_Ints], [r].[RequiredAssociate_Name], [r].[RequiredAssociate_String], [r3].[AssociateTypeRootEntityId], [r3].[Id], [r3].[Int], [r3].[Ints], [r3].[Name], [r3].[String], [r].[RequiredAssociate_OptionalNestedAssociate_Id], [r].[RequiredAssociate_OptionalNestedAssociate_Int], [r].[RequiredAssociate_OptionalNestedAssociate_Ints], [r].[RequiredAssociate_OptionalNestedAssociate_Name], [r].[RequiredAssociate_OptionalNestedAssociate_String], [r].[RequiredAssociate_RequiredNestedAssociate_Id], [r].[RequiredAssociate_RequiredNestedAssociate_Int], [r].[RequiredAssociate_RequiredNestedAssociate_Ints], [r].[RequiredAssociate_RequiredNestedAssociate_Name], [r].[RequiredAssociate_RequiredNestedAssociate_String]
+FROM [RootEntity] AS [r]
+LEFT JOIN (
+ SELECT [r1].[RootEntityId], [r1].[Id], [r1].[Int], [r1].[Ints], [r1].[Name], [r1].[String], [r2].[AssociateTypeRootEntityId], [r2].[AssociateTypeId], [r2].[Id] AS [Id0], [r2].[Int] AS [Int0], [r2].[Ints] AS [Ints0], [r2].[Name] AS [Name0], [r2].[String] AS [String0], [r1].[OptionalNestedAssociate_Id], [r1].[OptionalNestedAssociate_Int], [r1].[OptionalNestedAssociate_Ints], [r1].[OptionalNestedAssociate_Name], [r1].[OptionalNestedAssociate_String], [r1].[RequiredNestedAssociate_Id], [r1].[RequiredNestedAssociate_Int], [r1].[RequiredNestedAssociate_Ints], [r1].[RequiredNestedAssociate_Name], [r1].[RequiredNestedAssociate_String]
+ FROM [RelatedCollection] AS [r1]
+ LEFT JOIN [RelatedCollection_NestedCollection] AS [r2] ON [r1].[RootEntityId] = [r2].[AssociateTypeRootEntityId] AND [r1].[Id] = [r2].[AssociateTypeId]
+) AS [s] ON [r].[Id] = [s].[RootEntityId]
+LEFT JOIN [OptionalRelated_NestedCollection] AS [o] ON CASE
+ WHEN [r].[OptionalAssociate_Id] IS NOT NULL AND [r].[OptionalAssociate_Int] IS NOT NULL AND [r].[OptionalAssociate_Ints] IS NOT NULL AND [r].[OptionalAssociate_Name] IS NOT NULL AND [r].[OptionalAssociate_String] IS NOT NULL THEN [r].[Id]
+END = [o].[AssociateTypeRootEntityId]
+LEFT JOIN [RequiredRelated_NestedCollection] AS [r3] ON [r].[Id] = [r3].[AssociateTypeRootEntityId]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([r].[RequiredAssociate_RequiredNestedAssociate_Ints]) AS [r0]) = 3
+ORDER BY [r].[Id], [s].[RootEntityId], [s].[Id], [s].[AssociateTypeRootEntityId], [s].[AssociateTypeId], [s].[Id0], [o].[AssociateTypeRootEntityId], [o].[Id], [r3].[AssociateTypeRootEntityId], [r3].[Id]
+""");
+ }
+
+ public override async Task Select_Sum()
+ {
+ await base.Select_Sum();
+
+ AssertSql(
+ """
+SELECT (
+ SELECT ISNULL(SUM([r1].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r1])
+FROM [RootEntity] AS [r]
+WHERE (
+ SELECT ISNULL(SUM([r0].[value]), 0)
+ FROM OPENJSON([r].[RequiredAssociate_Ints]) WITH ([value] int '$') AS [r0]) >= 6
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..1fe2e80e
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryLibRedFixture : TPCInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..36042a6c
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,181 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceJsonQueryLibRedTest(TPCInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType]
+FROM [Coke] AS [c]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[ParentComplexType]
+FROM (
+ SELECT [d].[ParentComplexType]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[ParentComplexType]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[ParentComplexType]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[ParentComplexType]
+ FROM [Tea] AS [t]
+) AS [u]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([u].[ParentComplexType], '$.Nested')
+FROM (
+ SELECT [d].[ParentComplexType]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[ParentComplexType]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[ParentComplexType]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[ParentComplexType]
+ FROM [Tea] AS [t]
+) AS [u]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..7426d645
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,175 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPCInheritanceTableSplittingQueryLibRedTest(TPCInheritanceQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPCInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+WHERE [c].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE [u].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+WHERE [c].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE [u].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+UNION ALL
+SELECT [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+UNION ALL
+SELECT [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Lilt] AS [l]
+UNION ALL
+SELECT [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Tea] AS [t]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+UNION ALL
+SELECT [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Coke] AS [c]
+UNION ALL
+SELECT [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Lilt] AS [l]
+UNION ALL
+SELECT [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt]
+FROM [Tea] AS [t]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator]
+FROM (
+ SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator]
+ FROM [Drinks] AS [d]
+ UNION ALL
+ SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator]
+ FROM [Coke] AS [c]
+ UNION ALL
+ SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator]
+ FROM [Lilt] AS [l]
+ UNION ALL
+ SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator]
+ FROM [Tea] AS [t]
+) AS [u]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([u].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..053b64e9
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryLibRedFixture : TPHInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..2fd48f9f
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,122 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceJsonQueryLibRedTest(TPHInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPHInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..6d002a9c
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,125 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPHInheritanceTableSplittingQueryLibRedTest(
+ TPHInheritanceQueryLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPHInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE [d].[Discriminator] = 1
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c]
+ WHERE [c].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs
new file mode 100644
index 00000000..ee7185bf
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedFixture.cs
@@ -0,0 +1,11 @@
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryLibRedFixture : TPTInheritanceJsonQueryRelationalFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs
new file mode 100644
index 00000000..6f27ec8f
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQueryLibRedTest.cs
@@ -0,0 +1,145 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceJsonQueryLibRedTest(TPTInheritanceJsonQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : TPTInheritanceJsonQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([c].[ChildComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT JSON_QUERY([d].[ParentComplexType], '$.Nested')
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs
new file mode 100644
index 00000000..7da3e5c9
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQueryLibRedTest.cs
@@ -0,0 +1,148 @@
+using Microsoft.EntityFrameworkCore.Query.Inheritance;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Inheritance;
+
+public class TPTInheritanceTableSplittingQueryLibRedTest(
+ TPTInheritanceQueryLibRedFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : TPTInheritanceTableSplittingQueryRelationalTestBase(fixture, testOutputHelper)
+{
+ public override async Task Filter_on_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE [c].[ChildComplexType_Int] = 10
+""");
+ }
+
+ public override async Task Filter_on_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE [d].[ParentComplexType_Int] = 8
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_derived_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+WHERE [c].[ChildComplexType_Nested_NestedInt] = 58
+""");
+ }
+
+ public override async Task Filter_on_nested_complex_type_property_on_base_type(bool async)
+ {
+ await base.Filter_on_nested_complex_type_property_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE [d].[ParentComplexType_Nested_NestedInt] = 50
+""");
+ }
+
+ public override async Task Project_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_complex_type_on_base_type(bool async)
+ {
+ await base.Project_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_derived_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_derived_type(async);
+
+ AssertSql(
+ """
+SELECT [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+""");
+ }
+
+ public override async Task Project_nested_complex_type_on_base_type(bool async)
+ {
+ await base.Project_nested_complex_type_on_base_type(async);
+
+ AssertSql(
+ """
+SELECT [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt]
+FROM [Drinks] AS [d]
+""");
+ }
+
+ public override async Task Subquery_over_complex_collection(bool async)
+ {
+ await base.Subquery_over_complex_collection(async);
+
+ AssertSql(
+ """
+SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE
+ WHEN [t].[Id] IS NOT NULL THEN N'Tea'
+ WHEN [l].[Id] IS NOT NULL THEN N'Lilt'
+ WHEN [c].[Id] IS NOT NULL THEN N'Coke'
+END AS [Discriminator]
+FROM [Drinks] AS [d]
+LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id]
+LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id]
+LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([d].[ComplexTypeCollection], '$') WITH ([Int] int '$.Int') AS [c0]
+ WHERE [c0].[Int] > 59) = 2
+""");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs
new file mode 100644
index 00000000..70b6d612
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Query/Translations/JsonTranslationsLibRedTest.cs
@@ -0,0 +1,70 @@
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.Query.Translations;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Query.Translations;
+
+public class JsonTranslationsLibRedTest : JsonTranslationsRelationalTestBase<
+ JsonTranslationsLibRedTest.JsonTranslationsQueryLibRedFixture>
+{
+ public JsonTranslationsLibRedTest(JsonTranslationsQueryLibRedFixture fixture, ITestOutputHelper testOutputHelper)
+ : base(fixture)
+ {
+ Fixture.TestSqlLoggerFactory.Clear();
+ Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
+ }
+
+ public override async Task JsonPathExists_on_scalar_string_column()
+ {
+ await base.JsonPathExists_on_scalar_string_column();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonString], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_complex_property()
+ {
+ await base.JsonPathExists_on_complex_property();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonComplexType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public override async Task JsonPathExists_on_owned_entity()
+ {
+ await base.JsonPathExists_on_owned_entity();
+
+ AssertSql(
+ """
+SELECT [j].[Id], [j].[JsonString], [j].[JsonComplexType], [j].[JsonOwnedType]
+FROM [JsonEntities] AS [j]
+WHERE JSON_PATH_EXISTS([j].[JsonOwnedType], N'$.OptionalInt') = 1
+""");
+ }
+
+ public class JsonTranslationsQueryLibRedFixture : JsonTranslationsQueryFixtureBase, ITestSqlLoggerFactory
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+
+ protected override string RemoveJsonProperty(string column, string property)
+ => $"JSON_MODIFY({column}, '$.{property}', NULL)";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+
+ private void AssertSql(params string[] expected)
+ => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/RuntimeMigrationLibRedTest.cs b/test/EFCore.LibRed.FunctionalTests/RuntimeMigrationLibRedTest.cs
new file mode 100644
index 00000000..1ccd87fd
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/RuntimeMigrationLibRedTest.cs
@@ -0,0 +1,20 @@
+using EntityFrameworkCore.LibRed.Design.Internal;
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using System.Reflection;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests;
+
+public class RuntimeMigrationLibRedTest(RuntimeMigrationLibRedTest.RuntimeMigrationLibRedFixture fixture)
+ : RuntimeMigrationTestBase(fixture)
+{
+ protected override Assembly ProviderAssembly
+ => typeof(LibRedDesignTimeServices).Assembly;
+
+ public class RuntimeMigrationLibRedFixture : RuntimeMigrationFixtureBase
+ {
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/LibRedTypeFixture.cs b/test/EFCore.LibRed.FunctionalTests/Types/LibRedTypeFixture.cs
new file mode 100644
index 00000000..1a2f824a
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/LibRedTypeFixture.cs
@@ -0,0 +1,14 @@
+using EntityFrameworkCore.LibRed.FunctionalTests.TestUtilities;
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types;
+
+public abstract class LibRedTypeFixture : RelationalTypeFixtureBase
+{
+ protected override ITestStoreFactory TestStoreFactory
+ => LibRedTestStoreFactory.Instance;
+
+ public virtual bool UsingJsonType
+ => false;
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs
new file mode 100644
index 00000000..b9c922a4
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedBoolTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedBoolTypeTest(LibRedBoolTypeTest.BoolTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(1 AS bit)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='True'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bit '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='False'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bit) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='True'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bit) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":false,"Value":false}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='False'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(0 AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bit))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class BoolTypeFixture : LibRedTypeFixture
+ {
+ public override bool Value { get; } = true;
+ public override bool OtherValue { get; } = false;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs
new file mode 100644
index 00000000..b2406f70
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedByteArrayTypeTest.cs
@@ -0,0 +1,220 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedByteArrayTypeTest(LibRedByteArrayTypeTest.ByteArrayTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 8000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 0x010203
+""");
+ }
+
+ // byte[].Equals() does reference equality, so the base test doesn't work for byte arrays
+ public override Task Primitive_collection_in_query()
+ => Task.CompletedTask;
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='0x04050607' (Size = 8000)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with varbinary even on SQL Server 2025, as that type isn't supported
+ // (#36627).
+ // We also can't just wrap JSON_VALUE() with CAST(... AS varbinary(max)), as that would apply a SQL Server binary format
+ // conversion, and not base64. So we use OPENJSON which does perform base64 conversion.
+ AssertSql(
+ """
+@Fixture_Value='0x010203' (Size = 8000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+OUTER APPLY OPENJSON([j].[JsonContainer]) WITH ([Value] varbinary(max) '$.Value') AS [v]
+WHERE [v].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"BAUGBw==","Value":"BAUGBw=="}' (Nullable = false) (Size = 44)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='BAUGBw==' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'BAUGBw==')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteArrayTypeFixture : LibRedTypeFixture
+ {
+ public override byte[] Value { get; } = [1, 2, 3];
+ public override byte[] OtherValue { get; } = [4, 5, 6, 7];
+
+ public override Func Comparer { get; } = (a, b) => a.SequenceEqual(b);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs
new file mode 100644
index 00000000..d6b2ec93
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedGuidTypeTest.cs
@@ -0,0 +1,227 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedGuidTypeTest(LibRedGuidTypeTest.GuidTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '8f7331d6-cde9-44fb-8611-81fff686f280'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] uniqueidentifier '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='ae192c36-9004-49b2-b785-8be10d169627'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ // Note that the JSON_VALUE RETURNING clause is never used with uniqueidentifier even on SQL Server 2025, as that type isn't
+ // supported (#36627).
+ AssertSql(
+ """
+@Fixture_Value='8f7331d6-cde9-44fb-8611-81fff686f280'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS uniqueidentifier) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"ae192c36-9004-49b2-b785-8be10d169627","Value":"ae192c36-9004-49b2-b785-8be10d169627"}' (Nullable = false) (Size = 100)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'ae192c36-9004-49b2-b785-8be10d169627')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class GuidTypeFixture : LibRedTypeFixture
+ {
+ public override Guid Value { get; } = new("8f7331d6-cde9-44fb-8611-81fff686f280");
+ public override Guid OtherValue { get; } = new("ae192c36-9004-49b2-b785-8be10d169627");
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs
new file mode 100644
index 00000000..ac522cdb
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Miscellaneous/LibRedStringTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Miscellaneous;
+
+public class LibRedStringTypeTest(LibRedStringTypeTest.StringTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = N'foo'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='foo' (Size = 4000)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] nvarchar(max) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='bar' (Size = 4000)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING nvarchar(max)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='foo' (Size = 4000)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value') = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"bar","Value":"bar"}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='bar' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'bar')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class StringTypeFixture : LibRedTypeFixture
+ {
+ public override string Value { get; } = "foo";
+ public override string OtherValue { get; } = "bar";
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs
new file mode 100644
index 00000000..b5b10381
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedByteTypeTest.cs
@@ -0,0 +1,238 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedByteTypeTest(LibRedByteTypeTest.ByteTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(0 AS tinyint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='0' (Size = 1)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] tinyint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='255' (Size = 1)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING tinyint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='0' (Size = 1)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS tinyint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":255,"Value":255}' (Nullable = false) (Size = 30)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='255' (Size = 1)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(255 AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS tinyint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ByteTypeFixture : LibRedTypeFixture
+ {
+ public override byte Value { get; } = byte.MinValue;
+ public override byte OtherValue { get; } = byte.MaxValue;
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs
new file mode 100644
index 00000000..de486a8f
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDecimalTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedDecimalTypeTest(LibRedDecimalTypeTest.DecimalTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 30.5
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] decimal(18,2) '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30' (Precision = 18) (Scale = 2)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING decimal(18,2)) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5' (Precision = 18) (Scale = 2)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS decimal(18,2)) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30' (Precision = 18) (Scale = 2)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS decimal(18,2)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DecimalTypeFixture : LibRedTypeFixture
+ {
+ public override decimal Value { get; } = 30.5m;
+ public override decimal OtherValue { get; } = 30m;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs
new file mode 100644
index 00000000..7e1925ef
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedDoubleTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedDoubleTypeTest(LibRedDoubleTypeTest.DoubleTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = 30.5E0
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] float '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING float) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS float) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 30.0E0)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS float))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DoubleTypeFixture : LibRedTypeFixture
+ {
+ public override double Value { get; } = 30.5d;
+ public override double OtherValue { get; } = 30d;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs
new file mode 100644
index 00000000..ecea4266
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedFloatTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedFloatTypeTest(LibRedFloatTypeTest.FloatTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(30.5 AS real)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='30.5'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] real '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='30'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING real) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='30.5'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS real) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":30,"Value":30}' (Nullable = false) (Size = 28)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='30'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(30 AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS real))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class FloatTypeFixture : LibRedTypeFixture
+ {
+ public override float Value { get; } = 30.5f;
+ public override float OtherValue { get; } = 30f;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs
new file mode 100644
index 00000000..c6f8d23f
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedIntTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedIntTypeTest(LibRedIntTypeTest.IntTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = -2147483648
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-2147483648'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] int '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2147483647'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING int) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-2147483648'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS int) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":2147483647,"Value":2147483647}' (Nullable = false) (Size = 44)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='2147483647'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', 2147483647)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS int))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class IntTypeFixture : LibRedTypeFixture
+ {
+ public override int Value { get; } = int.MinValue;
+ public override int OtherValue { get; } = int.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs
new file mode 100644
index 00000000..495c4ebb
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedLongTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedLongTypeTest(LibRedLongTypeTest.LongTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(-9223372036854775808 AS bigint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-9223372036854775808'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] bigint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='9223372036854775807'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING bigint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-9223372036854775808'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS bigint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":9223372036854775807,"Value":9223372036854775807}' (Nullable = false) (Size = 62)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='9223372036854775807'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(9223372036854775807 AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS bigint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class LongTypeFixture : LibRedTypeFixture
+ {
+ public override long Value { get; } = long.MinValue;
+ public override long OtherValue { get; } = long.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs
new file mode 100644
index 00000000..a9861aad
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Numeric/LibRedShortTypeTest.cs
@@ -0,0 +1,233 @@
+using Microsoft.EntityFrameworkCore.Types;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Numeric;
+
+public class LibRedShortTypeTest(LibRedShortTypeTest.ShortTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = CAST(-32768 AS smallint)
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='-32768'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] smallint '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='32767'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING smallint) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='-32768'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS smallint) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":32767,"Value":32767}' (Nullable = false) (Size = 34)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_OtherValue='32767'
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(32767 AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', CAST(JSON_VALUE([j].[JsonContainer], '$.OtherValue') AS smallint))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', [j].[OtherValue])
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class ShortTypeFixture : LibRedTypeFixture
+ {
+ public override short Value { get; } = short.MinValue;
+ public override short OtherValue { get; } = short.MaxValue;
+ }
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs
new file mode 100644
index 00000000..d71b7a1a
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateOnlyTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedDateOnlyTypeTest(LibRedDateOnlyTypeTest.DateTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] date '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='05/03/2022' (DbType = Date)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING date) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='01/05/2020' (DbType = Date)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS date) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03","Value":"2022-05-03"}' (Nullable = false) (Size = 48)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTypeFixture : LibRedTypeFixture
+ {
+ public override DateOnly Value { get; } = new(2020, 1, 5);
+ public override DateOnly OtherValue { get; } = new(2022, 5, 3);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs
new file mode 100644
index 00000000..48a4cb7c
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTime2TypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTime2TypeTest(LibRedDateTime2TypeTest.DateTime2TypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.0000000'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime2 '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetime2) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime2) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTime2TypeFixture : LibRedTypeFixture
+ {
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs
new file mode 100644
index 00000000..210f8a4b
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeOffsetTypeTest.cs
@@ -0,0 +1,241 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTimeOffsetTypeTest(
+ LibRedDateTimeOffsetTypeTest.DateTimeOffsetTypeFixture fixture,
+ ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.0000000+02:00'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetimeoffset '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2020-01-05T12:30:45.0000000+03:00'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING datetimeoffset) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000+02:00'
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetimeoffset) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2020-01-05T12:30:45+03:00","Value":"2020-01-05T12:30:45+03:00"}' (Nullable = false) (Size = 78)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2020-01-05T12:30:45+03:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2020-01-05T12:30:45+03:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeOffsetTypeFixture : LibRedTypeFixture
+ {
+ public override DateTimeOffset Value { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(2));
+ public override DateTimeOffset OtherValue { get; } = new(2020, 1, 5, 12, 30, 45, TimeSpan.FromHours(3));
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs
new file mode 100644
index 00000000..608c9eed
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedDateTimeTypeTest.cs
@@ -0,0 +1,229 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedDateTimeTypeTest(LibRedDateTimeTypeTest.DateTimeTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '2020-01-05T12:30:45.000'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] datetime '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='2022-05-03T00:00:00.0000000' (DbType = DateTime)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ AssertSql(
+ """
+@Fixture_Value='2020-01-05T12:30:45.0000000' (DbType = DateTime)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS datetime) = @Fixture_Value
+""");
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"2022-05-03T00:00:00","Value":"2022-05-03T00:00:00"}' (Nullable = false) (Size = 66)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='2022-05-03T00:00:00' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'2022-05-03T00:00:00')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class DateTimeTypeFixture : LibRedTypeFixture
+ {
+ // The default mapping for .NET DateTime is datetime2; this tests the non-default (and discouraged) datetime type.
+ public override string StoreType
+ => "datetime";
+
+ public override DateTime Value { get; } = new(2020, 1, 5, 12, 30, 45, DateTimeKind.Unspecified);
+ public override DateTime OtherValue { get; } = new(2022, 5, 3, 0, 0, 0, DateTimeKind.Unspecified);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs
new file mode 100644
index 00000000..150c7a54
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeOnlyTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedTimeOnlyTypeTest(LibRedTimeOnlyTypeTest.TimeOnlyTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase(fixture, testOutputHelper)
+{
+ public override async Task Equality_in_query_with_parameter()
+ {
+ await base.Equality_in_query_with_parameter();
+
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = @Fixture_Value
+""");
+ }
+
+ public override async Task Equality_in_query_with_constant()
+ {
+ await base.Equality_in_query_with_constant();
+
+ AssertSql(
+ """
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE [t].[Value] = '12:30:45'
+""");
+ }
+
+ public override async Task Primitive_collection_in_query()
+ {
+ await base.Primitive_collection_in_query();
+
+ AssertSql(
+ """
+@value='12:30' (DbType = Time)
+
+SELECT TOP(2) [t].[Id], [t].[ArrayValue], [t].[OtherValue], [t].[Value]
+FROM [TypeEntity] AS [t]
+WHERE (
+ SELECT COUNT(*)
+ FROM OPENJSON([t].[ArrayValue]) WITH ([value] time '$') AS [a]
+ WHERE [a].[value] = @value) = 2
+""");
+ }
+
+ public override async Task SaveChanges()
+ {
+ await base.SaveChanges();
+
+ AssertSql(
+ """
+@p1='1'
+@p0='14:00' (DbType = Time)
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [TypeEntity] SET [Value] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ #region JSON
+
+ public override async Task Query_property_within_json()
+ {
+ await base.Query_property_within_json();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE JSON_VALUE([j].[JsonContainer], '$.Value' RETURNING time) = @Fixture_Value
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@Fixture_Value='12:30' (DbType = Time)
+
+SELECT TOP(2) [j].[Id], [j].[OtherValue], [j].[Value], [j].[JsonContainer]
+FROM [JsonTypeEntity] AS [j]
+WHERE CAST(JSON_VALUE([j].[JsonContainer], '$.Value') AS time) = @Fixture_Value
+""");
+ }
+ }
+
+ public override async Task SaveChanges_within_json()
+ {
+ await base.SaveChanges_within_json();
+
+ AssertSql(
+ """
+@p0='{"OtherValue":"14:00:00.0000000","Value":"14:00:00.0000000"}' (Nullable = false) (Size = 60)
+@p1='1'
+
+SET IMPLICIT_TRANSACTIONS OFF;
+SET NOCOUNT ON;
+UPDATE [JsonTypeEntity] SET [JsonContainer] = @p0
+OUTPUT 1
+WHERE [Id] = @p1;
+""");
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_parameter()
+ {
+ await base.ExecuteUpdate_within_json_to_parameter();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+@complex_type_Fixture_OtherValue='14:00:00.0000000' (Size = 4000)
+
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', @complex_type_Fixture_OtherValue)
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_constant()
+ {
+ await base.ExecuteUpdate_within_json_to_constant();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', N'14:00:00.0000000')
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ public override async Task ExecuteUpdate_within_json_to_another_json_property()
+ {
+ await base.ExecuteUpdate_within_json_to_another_json_property();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue' RETURNING nvarchar(max)))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE([j].[JsonContainer], '$.OtherValue'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ // TODO: Currently failing on Helix only, see #36746
+ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
+ {
+ await base.ExecuteUpdate_within_json_to_nonjson_column();
+
+ if (Fixture.UsingJsonType)
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [JsonContainer].modify('$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ else
+ {
+ AssertSql(
+ """
+SET NOCOUNT OFF;
+UPDATE [j]
+SET [j].[JsonContainer] = JSON_MODIFY([j].[JsonContainer], '$.Value', JSON_VALUE(JSON_OBJECT('v': [j].[OtherValue]), '$.v'))
+FROM [JsonTypeEntity] AS [j]
+""");
+ }
+ }
+
+ #endregion JSON
+
+ public class TimeOnlyTypeFixture : LibRedTypeFixture
+ {
+ public override TimeOnly Value { get; } = new(12, 30, 45);
+ public override TimeOnly OtherValue { get; } = new(14, 0, 0);
+ }
+
+ [Fact]
+ public virtual void Check_all_tests_overridden()
+ => TestHelpers.AssertAllMethodsOverridden(GetType());
+}
diff --git a/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs
new file mode 100644
index 00000000..e5b670bd
--- /dev/null
+++ b/test/EFCore.LibRed.FunctionalTests/Types/Temporal/LibRedTimeSpanTypeTest.cs
@@ -0,0 +1,239 @@
+using Microsoft.EntityFrameworkCore.TestUtilities;
+using Microsoft.EntityFrameworkCore.Types;
+using System;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace EntityFrameworkCore.LibRed.FunctionalTests.Types.Temporal;
+
+public class LibRedTimeSpanTypeTest(LibRedTimeSpanTypeTest.TimeSpanTypeFixture fixture, ITestOutputHelper testOutputHelper)
+ : RelationalTypeTestBase