指定 Azure SQL 数据库选项Specifying Azure SQL Database Options

备注

此 API 是 EF Core 3.1 中新增的。This API is new in EF Core 3.1.

Azure SQL 数据库提供了 各种定价选项 ,这些选项通常通过 Azure 门户进行配置。Azure SQL Database provides a variety of pricing options that are usually configured through the Azure Portal. 但是,如果使用 EF Core 迁移 来管理架构,则可以在模型本身中指定所需的选项。However if you are managing the schema using EF Core migrations you can specify the desired options in the model itself.

您可以使用 HasServiceTier指定数据库 (版) 的服务层:You can specify the service tier of the database (EDITION) using HasServiceTier:

modelBuilder.HasServiceTier("BusinessCritical");

您可以使用 HasDatabaseMaxSize指定数据库的最大大小:You can specify the maximum size of the database using HasDatabaseMaxSize:

modelBuilder.HasDatabaseMaxSize("2 GB");

您可以使用 HasPerformanceLevel) (SERVICE_OBJECTIVE 指定数据库的性能级别:You can specify the performance level of the database (SERVICE_OBJECTIVE) using HasPerformanceLevel:

modelBuilder.HasPerformanceLevel("BC_Gen4_1");

使用 HasPerformanceLevelSql 配置弹性池,因为该值不是字符串文本:Use HasPerformanceLevelSql to configure the elastic pool, since the value is not a string literal:

modelBuilder.HasPerformanceLevelSql("ELASTIC_POOL ( name = myelasticpool )");

提示

可以在 ALTER DATABASE 文档中找到所有支持的值。You can find all the supported values in the ALTER DATABASE documentation.