-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs for configuring Azure SQL Database options
Fixes #1808
- Loading branch information
1 parent
52cf754
commit 49a768a
Showing
13 changed files
with
170 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
34 changes: 34 additions & 0 deletions
34
entity-framework/core/providers/sql-server/azure-sql-database.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Microsoft SQL Server Database Provider - Azure SQL Database Options - EF Core | ||
description: How to specify the service tier and performance level for Azure SQL Database with the SQL Server Entity Framework Core Database Provider | ||
author: AndriySvyryd | ||
ms.author: ansvyryd | ||
ms.date: 11/05/2016 | ||
uid: core/providers/sql-server/azure-sql-database | ||
--- | ||
# Specifying Azure SQL Database Options | ||
|
||
>[!NOTE] | ||
> This API is new in EF Core 3.1. | ||
Azure SQL Database provides [a variety of pricing options](https://azure.microsoft.com/en-us/pricing/details/sql-database/single/) that are usually configured through the Azure Portal. However if you are managing the schema using [EF Core migrations](xref:core/managing-schemas/migrations/index) you can specify the desired options in the model itself. | ||
|
||
You can specify the service tier of the database (EDITION) using [HasServiceTier](/dotnet/api/Microsoft.EntityFrameworkCore.SqlServerModelBuilderExtensions.HasServiceTier): | ||
|
||
[!code-csharp[HasServiceTier](../../../../samples/core/SqlServer/AzureDatabase/AzureSqlContext.cs?name=HasServiceTier)] | ||
|
||
You can specify the maximum size of the database using [HasDatabaseMaxSize](/dotnet/api/Microsoft.EntityFrameworkCore.SqlServerModelBuilderExtensions.HasDatabaseMaxSize): | ||
|
||
[!code-csharp[HasDatabaseMaxSize](../../../../samples/core/SqlServer/AzureDatabase/AzureSqlContext.cs?name=HasDatabaseMaxSize)] | ||
|
||
You can specify the performance level of the database (SERVICE_OBJECTIVE) using [HasPerformanceLevel](/dotnet/api/Microsoft.EntityFrameworkCore.SqlServerModelBuilderExtensions.HasPerformanceLevel): | ||
|
||
[!code-csharp[HasPerformanceLevel](../../../../samples/core/SqlServer/AzureDatabase/AzureSqlContext.cs?name=HasPerformanceLevel)] | ||
|
||
Use [HasPerformanceLevelSql](/dotnet/api/Microsoft.EntityFrameworkCore.SqlServerModelBuilderExtensions.HasPerformanceLevelSql) to configure the elastic pool, since the value is not a string literal: | ||
|
||
[!code-csharp[HasPerformanceLevel](../../../../samples/core/SqlServer/AzureDatabase/AzureSqlContext.cs?name=HasPerformanceLevelSql)] | ||
|
||
|
||
>[!TIP] | ||
> You can find all the supported values in the [ALTER DATABASE documentation](/sql/t-sql/statements/alter-database-transact-sql?view=azuresqldb-current). |
This file contains 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
18 changes: 6 additions & 12 deletions
18
entity-framework/core/providers/sql-server/memory-optimized-tables.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
--- | ||
title: Microsoft SQL Server Database Provider - Memory-Optimized Tables - EF Core | ||
author: rowanmiller | ||
description: How to use Memory-Optimized Tables with the SQL Server Entity Framework Core Database Provider | ||
author: AndriySvyryd | ||
ms.author: ansvyryd | ||
ms.date: 10/27/2016 | ||
ms.assetid: 2e007c82-c6e4-45bb-8129-851b79ec1a0a | ||
uid: core/providers/sql-server/memory-optimized-tables | ||
--- | ||
|
||
# Memory-Optimized Tables support in SQL Server EF Core Database Provider | ||
|
||
[Memory-Optimized Tables](https://docs.microsoft.com/sql/relational-databases/in-memory-oltp/memory-optimized-tables) are a feature of SQL Server where the entire table resides in memory. A second copy of the table data is maintained on disk, but only for durability purposes. Data in memory-optimized tables is only read from disk during database recovery. For example, after a server restart. | ||
[Memory-Optimized Tables](/sql/relational-databases/in-memory-oltp/memory-optimized-tables) are a feature of SQL Server where the entire table resides in memory. A second copy of the table data is maintained on disk, but only for durability purposes. Data in memory-optimized tables is only read from disk during database recovery. For example, after a server restart. | ||
|
||
## Configuring a memory-optimized table | ||
|
||
You can specify that the table an entity is mapped to is memory-optimized. When using EF Core to create and maintain a database based on your model (either with migrations or `Database.EnsureCreated()`), a memory-optimized table will be created for these entities. | ||
You can specify that the table an entity is mapped to is memory-optimized. When using EF Core to create and maintain a database based on your model (either with [migrations](xref:core/managing-schemas/migrations/index) or [EnsureCreated](/dotnet/api/Microsoft.EntityFrameworkCore.Storage.IDatabaseCreator.EnsureCreated)), a memory-optimized table will be created for these entities. | ||
|
||
``` csharp | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>() | ||
.ForSqlServerIsMemoryOptimized(); | ||
} | ||
``` | ||
[!code-csharp[IsMemoryOptimized](../../../../samples/core/SqlServer/InMemory/InMemoryContext.cs?name=IsMemoryOptimized)] |
2 changes: 1 addition & 1 deletion
2
...entAPI/Relational/ForSqlServerHasIndex.cs → ...ling/FluentAPI/Relational/IndexInclude.cs
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace SqlServer.AzureDatabase | ||
{ | ||
public class AzureSqlContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
{ | ||
optionsBuilder.UseSqlServer("Server=tcp:[serverName].database.windows.net;Database=myDataBase;User ID=[Login]@[serverName];Password=myPassword];Trusted_Connection=False;Encrypt=True;"); | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
#region HasServiceTier | ||
modelBuilder.HasServiceTier("BusinessCritical"); | ||
#endregion | ||
|
||
#region HasDatabaseMaxSize | ||
modelBuilder.HasDatabaseMaxSize("2 GB"); | ||
#endregion | ||
|
||
#region HasPerformanceLevelSql | ||
modelBuilder.HasPerformanceLevelSql("ELASTIC_POOL ( name = unicornhack )"); | ||
#endregion | ||
|
||
#region HasPerformanceLevel | ||
modelBuilder.HasPerformanceLevel("BC_Gen4_1"); | ||
#endregion | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SqlServer.AzureDatabase | ||
{ | ||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace SqlServer.InMemory | ||
{ | ||
public class Blog | ||
{ | ||
public int BlogId { get; set; } | ||
public string Url { get; set; } | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace SqlServer.InMemory | ||
{ | ||
public class InMemoryContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs { get; set; } | ||
|
||
#region IsMemoryOptimized | ||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
modelBuilder.Entity<Blog>().IsMemoryOptimized(); | ||
} | ||
#endregion | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace SqlServer.InMemory | ||
{ | ||
public class Sample | ||
{ | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace SqlServer | ||
{ | ||
public class Program | ||
{ | ||
static void Main() | ||
{ | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0-preview2.19525.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |