Bump default SQL Server compat level to 160 (SQL Server 2022)#38199
Open
roji wants to merge 2 commits intodotnet:mainfrom
Open
Bump default SQL Server compat level to 160 (SQL Server 2022)#38199roji wants to merge 2 commits intodotnet:mainfrom
roji wants to merge 2 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates EF Core SQL Server provider defaults to align with SQL Server 2022 by bumping the default SQL Server compatibility level used by the provider.
Changes:
- Bump
SqlServerDefaultCompatibilityLevelfrom 150 (SQL Server 2019) to 160 (SQL Server 2022). - Update the inline compatibility-level reference comments in
SqlServerOptionsExtension.
There was a problem hiding this comment.
Pull request overview
Updates EF Core’s SQL Server provider default compatibility level to 160 (SQL Server 2022) and consolidates version-dependent SQL Server test coverage by branching on runtime server capabilities instead of maintaining separate per-version test suites.
Changes:
- Bump default SQL Server compatibility level from 150 to 160.
- Remove SQL Server 160-specific test suites and fold their assertions into the main SQL Server test classes via capability checks.
- Configure key SQL Server test fixtures to set EF compatibility level from the current test server environment.
Reviewed changes
Copilot reviewed 26 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServerTest.cs | Makes TrimStart/TrimEnd parameterized translations conditional on SQL Server 2022 function support; adds baselines for supported servers. |
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServer160Test.cs | Removes dedicated SQL Server 160 test class (now covered via conditional logic). |
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServerTest.cs | Enables LEAST/GREATEST translation baselines when SQL Server 2022 functions are supported; otherwise expects translation failure. |
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServer160Test.cs | Removes dedicated SQL Server 160 math translation test class. |
| test/EFCore.SqlServer.FunctionalTests/Query/Translations/BasicTypesQuerySqlServerFixture.cs | Sets compatibility level from environment for translation tests; removes the 160-specific fixture. |
| test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs | Adds branching SQL baselines for JSON type support and SQL Server 2022 LEAST/GREATEST support; fixture sets compatibility from environment. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs | Updates baselines to branch on SQL Server 2022 function support (LEAST in TOP/FETCH). |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs | Updates split-include baselines to branch on SQL Server 2022 function support. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs | Updates split-include (no-tracking) baselines to branch on SQL Server 2022 function support. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs | Updates baselines to branch on SQL Server 2022 function support (LEAST in TOP). |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs | Sets compatibility level from environment for Northwind SQL Server test contexts. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs | Updates several baselines to branch on SQL Server 2022 function support (LEAST usage). |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs | Updates include-query baselines to branch on SQL Server 2022 function support. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs | Updates include-query (no-tracking) baselines to branch on SQL Server 2022 function support. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs | Removes dedicated SQL Server 160 Northwind functions test suite. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs | Updates EF.Property include-query baselines to branch on SQL Server 2022 function support. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs | Enables LEAST/GREATEST translation baselines when SQL Server 2022 functions are supported; otherwise expects translation failure. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServer160Test.cs | Removes dedicated SQL Server 160 Northwind DbFunctions test suite. |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs | Branches baselines on JSON type support (JSON_VALUE RETURNING vs non-RETURNING). |
| test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs | Updates baselines to branch on SQL Server 2022 function support (LEAST in TOP). |
| test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs | Branches baseline on SQL Server 2022 function support (GREATEST vs older pattern). |
| test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerFixture.cs | Sets compatibility level from environment for shared-type complex navigation tests. |
| test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs | Branches baseline on SQL Server 2022 function support (GREATEST vs older pattern). |
| test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs | Sets compatibility level from environment for complex navigation tests. |
| src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs | Updates public API docs to reflect default compatibility level 160. |
| src/EFCore.SqlServer/Infrastructure/Internal/SqlServerOptionsExtension.cs | Updates provider default compatibility level constant to 160 and refreshes compatibility-level reference comment. |
| => SqlServerNorthwindTestStoreFactory.Instance; | ||
|
|
||
| public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| => TestEnvironment.SetCompatibilityLevelFromEnvironment(base.AddOptions(builder)); |
| => SqlServerTestStoreFactory.Instance; | ||
|
|
||
| public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| => TestEnvironment.SetCompatibilityLevelFromEnvironment(base.AddOptions(builder)); |
Comment on lines
+13
to
+14
| public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| => TestEnvironment.SetCompatibilityLevelFromEnvironment(base.AddOptions(builder)); |
| => SqlServerTestStoreFactory.Instance; | ||
|
|
||
| public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| => TestEnvironment.SetCompatibilityLevelFromEnvironment(base.AddOptions(builder)); |
| => (TestSqlLoggerFactory)ListLoggerFactory; | ||
|
|
||
| public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
| => TestEnvironment.SetCompatibilityLevelFromEnvironment(base.AddOptions(builder)); |
AndriySvyryd
approved these changes
May 1, 2026
Member
AndriySvyryd
left a comment
There was a problem hiding this comment.
Pending Azure SQL special-casing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Aside from bumping the default compat level, this also cleans up SQL Server query tests, removing entire test suites which were dedicated to testing different versions of SQL Server. Now that we have reliable, constant testing of the different SQL Server versions in Github Actions, we can rely on CI for proper, multi-version coverage.
Aside from simplifying everything and keeping all the different SQL variants for different versions in a single place/test, this also removes cases where we duplicated an entire large test suite just because one test inside it needed to vary its SQL across versions.
Closes #38198