title | description | author | ms.date | uid |
---|---|---|---|---|
Microsoft SQL Server Database Provider - Azure SQL Database Options - EF Core |
How to specify the service tier and performance level for Azure SQL Database with the SQL Server Entity Framework Core Database Provider |
AndriySvyryd |
11/05/2019 |
core/providers/sql-server/azure-sql-database |
Azure SQL Database provides a variety of pricing options that are usually configured through the Azure Portal. However if you are managing the schema using EF Core migrations you can specify the desired options in the model itself.
You can specify the service tier of the database (EDITION) using HasServiceTier:
[!code-csharpHasServiceTier]
You can specify the maximum size of the database using HasDatabaseMaxSize:
[!code-csharpHasDatabaseMaxSize]
You can specify the performance level of the database (SERVICE_OBJECTIVE) using HasPerformanceLevel:
[!code-csharpHasPerformanceLevel]
Use HasPerformanceLevelSql to configure the elastic pool, since the value is not a string literal:
[!code-csharpHasPerformanceLevel]
Tip
You can find all the supported values in the ALTER DATABASE documentation.