Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static bool IsHiddenColumnsSupported

try
{
_supportsHiddenColumns = ((GetProductMajorVersion() >= 13 && GetEngineEdition() != 6) || IsAzureSql) && GetCompatibilityLevel() >= 130;
_supportsHiddenColumns = GetEngineEdition() != 6 && GetCompatibilityLevel() >= 130;
}
catch (PlatformNotSupportedException)
{
Expand Down Expand Up @@ -259,7 +259,7 @@ public static bool IsTemporalTablesCascadeDeleteSupported

try
{
_supportsTemporalTablesCascadeDelete = (GetProductMajorVersion() >= 14 || IsAzureSql) && GetCompatibilityLevel() >= 140;
_supportsTemporalTablesCascadeDelete = GetCompatibilityLevel() >= 140;
}
Comment thread
ErikEJ marked this conversation as resolved.
catch (PlatformNotSupportedException)
{
Expand All @@ -286,7 +286,7 @@ public static bool IsUtf8Supported

try
{
_supportsUtf8 = (GetProductMajorVersion() >= 15 || IsAzureSql) && GetCompatibilityLevel() >= 150;
_supportsUtf8 = GetCompatibilityLevel() >= 150;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -313,7 +313,7 @@ public static bool SupportsJsonPathExpressions

try
{
_supportsJsonPathExpressions = (GetProductMajorVersion() >= 14 || IsAzureSql) && GetCompatibilityLevel() >= 140;
_supportsJsonPathExpressions = GetCompatibilityLevel() >= 140;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -340,7 +340,7 @@ public static bool IsFunctions2017Supported

try
{
_supportsFunctions2017 = (GetProductMajorVersion() >= 14 || IsAzureSql) && GetCompatibilityLevel() >= 140;
_supportsFunctions2017 = GetCompatibilityLevel() >= 140;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -367,7 +367,7 @@ public static bool IsFunctions2019Supported

try
{
_supportsFunctions2019 = (GetProductMajorVersion() >= 15 || IsAzureSql) && GetCompatibilityLevel() >= 150;
_supportsFunctions2019 = GetCompatibilityLevel() >= 150;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -394,7 +394,7 @@ public static bool IsFunctions2022Supported

try
{
_supportsFunctions2022 = (GetProductMajorVersion() >= 16 || IsAzureSql) && GetCompatibilityLevel() >= 160;
_supportsFunctions2022 = GetCompatibilityLevel() >= 160;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -421,7 +421,7 @@ public static bool IsJsonTypeSupported

try
{
_isJsonTypeSupported = (GetProductMajorVersion() >= 17 || IsAzureSql) && GetCompatibilityLevel() >= 170;
_isJsonTypeSupported = GetCompatibilityLevel() >= 170;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -448,8 +448,7 @@ public static bool IsVectorTypeSupported

try
{
_isVectorTypeSupported = ((!IsLocalDb && GetProductMajorVersion() >= 17) || IsAzureSql)
&& GetCompatibilityLevel() >= 170;
_isVectorTypeSupported = !IsLocalDb && GetCompatibilityLevel() >= 170;
}
catch (PlatformNotSupportedException)
{
Expand All @@ -464,7 +463,11 @@ public static byte SqlServerMajorVersion
=> GetProductMajorVersion();

public static DbContextOptionsBuilder SetCompatibilityLevelFromEnvironment(DbContextOptionsBuilder builder)
=> builder.UseSqlServerCompatibilityLevel(SqlServerMajorVersion * 10);
{
builder.UseSqlServerCompatibilityLevel(GetCompatibilityLevel());

return builder;
Comment thread
ErikEJ marked this conversation as resolved.
}

public static string? ElasticPoolName { get; } = Config["ElasticPoolName"];

Expand Down Expand Up @@ -519,7 +522,7 @@ private static int GetCompatibilityLevel()
sqlConnection.Open();

using var command = new SqlCommand(
"SELECT compatibility_level FROM sys.databases WHERE [name] = 'master';", sqlConnection);
"SELECT compatibility_level FROM sys.databases WHERE [name] = 'model';", sqlConnection);
_compatibilityLevel = (byte)command.ExecuteScalar();

return _compatibilityLevel.Value;
Expand Down
Loading