语言

SqlServerDbContextOptionsBuilder.UseCompatibilityLevel(Int32) 方法

定义

设置 EF Core 在与数据库交互时将使用的SQL Server兼容级别。 这允许将 EF Core 配置为使用较旧的(或更新)版本的SQL Server。 默认值为 160 (SQL Server 2022)。

public virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder UseCompatibilityLevel(int compatibilityLevel);
abstract member UseCompatibilityLevel : int -> Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder
override this.UseCompatibilityLevel : int -> Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder
Public Overridable Function UseCompatibilityLevel (compatibilityLevel As Integer) As SqlServerDbContextOptionsBuilder

参数

compatibilityLevel
Int32

要用于数据库的兼容级别。

返回

注解

有关详细信息和示例,请参阅有关兼容级别的使用 DbContextOptions 和SQL Server文档。

适用于