Skip to content

Commit

Permalink
Fix slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam committed Oct 12, 2020
1 parent 43d0cd4 commit 9c200e6
Show file tree
Hide file tree
Showing 50 changed files with 446 additions and 446 deletions.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ Here are some examples of [DFM code snippet syntax](http://dotnet.github.io/docf

To render an entire code file as a snippet:

``` none
```none
[!code-csharp[Main](../../../samples/core/saving/Program.cs)]
```

To render a portion of a file as a snippet by using line numbers:

``` none
```none
[!code-csharp[Main](../../../samples/core/saving/Program.cs?range=1-10]
```

For C# snippets, you can reference a [C# region](https://msdn.microsoft.com/library/9a1ybwek.aspx). Use regions rather than line numbers. Line numbers in a code file tend to change and get out of sync with line number references in Markdown. C# regions can be nested. If you reference the outer region, the inner `#region` and `#endregion` directives are not rendered in a snippet.

To render a C# region named "snippet_Example":

``` none
```none
[!code-csharp[Main](../../../samples/core/saving/Program.cs?name=snippet_Example)]
```

To highlight selected lines in a rendered snippet (usually renders as yellow background color):

``` none
```none
[!code-csharp[Main](../../../samples/core/saving/Program.cs?name=snippet_Example&highlight=1-3,10,20-25)]
```

Expand All @@ -69,7 +69,7 @@ DocFX requires the .NET Framework on Windows, or Mono for Linux or macOS.
* Add DocFX to your PATH.
* In a command-line window, navigate to the cloned repository (which contains the *docfx.json* file) and run the following command:

``` console
```console
docfx -t default --serve
```

Expand All @@ -82,7 +82,7 @@ DocFX requires the .NET Framework on Windows, or Mono for Linux or macOS.
* Extract to `\bin\docfx`.
* Create an alias for **docfx**:

``` console
```console
function docfx {
mono $HOME/bin/docfx/docfx.exe
}
Expand Down
6 changes: 3 additions & 3 deletions entity-framework/core/get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dotnet add package Microsoft.EntityFrameworkCore.Sqlite
* **Tools > NuGet Package Manager > Package Manager Console**
* Run the following commands:

``` PowerShell
```powershell
Install-Package Microsoft.EntityFrameworkCore.Sqlite
```

Expand Down Expand Up @@ -113,7 +113,7 @@ The following steps use [migrations](xref:core/managing-schemas/migrations/index

* Run the following commands in **Package Manager Console (PMC)**

``` PowerShell
```powershell
Install-Package Microsoft.EntityFrameworkCore.Tools
Add-Migration InitialCreate
Update-Database
Expand Down Expand Up @@ -144,7 +144,7 @@ Visual Studio uses an inconsistent working directory when running .NET Core cons
* Right-click on the project and select **Edit Project File**
* Just below the *TargetFramework* property, add the following:

``` XML
```xml
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
```

Expand Down
4 changes: 2 additions & 2 deletions entity-framework/core/get-started/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ For more information, see [NuGet Package Manager Dialog](/nuget/tools/package-ma

* To install the SQL Server provider, run the following command in the Package Manager Console:

``` PowerShell
```powershell
Install-Package Microsoft.EntityFrameworkCore.SqlServer
```

Expand Down Expand Up @@ -110,7 +110,7 @@ Although you can also use the `dotnet ef` commands from the Package Manager Cons

To get the Package Manager Console tools for EF Core, install the `Microsoft.EntityFrameworkCore.Tools` package. For example, from Visual Studio:

``` PowerShell
```powershell
Install-Package Microsoft.EntityFrameworkCore.Tools
```

Expand Down
8 changes: 4 additions & 4 deletions entity-framework/core/managing-schemas/ensure-created.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Transitioning from EnsureCreated to Migrations is not a seamless experience. The

The EnsureDeleted method will drop the database if it exists. If you don't have the appropriate permissions, an exception is thrown.

``` csharp
```csharp
// Drop the database if it exists
dbContext.Database.EnsureDeleted();
```
Expand All @@ -29,7 +29,7 @@ dbContext.Database.EnsureDeleted();

EnsureCreated will create the database if it doesn't exist and initialize the database schema. If any tables exist (including tables for another DbContext class), the schema won't be initialized.

``` csharp
```csharp
// Create the database if it doesn't exist
dbContext.Database.EnsureCreated();
```
Expand All @@ -41,15 +41,15 @@ dbContext.Database.EnsureCreated();

To get the SQL used by EnsureCreated, you can use the GenerateCreateScript method.

``` csharp
```csharp
var sql = dbContext.Database.GenerateCreateScript();
```

## Multiple DbContext classes

EnsureCreated only works when no tables are present in the database. If needed, you can write your own check to see if the schema needs to be initialized, and use the underlying IRelationalDatabaseCreator service to initialize the schema.

``` csharp
```csharp
// TODO: Check whether the schema needs to be initialized
// Initialize the schema for this DbContext
Expand Down
10 changes: 5 additions & 5 deletions entity-framework/core/managing-schemas/migrations/applying.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can use a `from` that is newer than the `to` in order to generate a rollback

The following generates a SQL script from a blank database to the latest migration:

``` powershell
```powershell
Script-Migration
```

Expand Down Expand Up @@ -100,7 +100,7 @@ dotnet ef migrations script --idempotent

#### [Visual Studio](#tab/vs)

``` powershell
```powershell
Script-Migration -Idempotent
```

Expand Down Expand Up @@ -136,13 +136,13 @@ Note that this can be used to roll back to an earlier migration as well.

The following updates your database to the latest migration:

``` powershell
```powershell
Update-Database
```

The following updates your database to a given migration:

``` powershell
```powershell
Update-Database AddNewTables
```

Expand All @@ -167,7 +167,7 @@ It's possible for the application itself to apply migrations programmatically, t

To apply migrations programmatically, call `context.Database.Migrate()`. For example, a typical ASP.NET application can do the following:

```c#
```csharp
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
Expand Down
12 changes: 6 additions & 6 deletions entity-framework/core/managing-schemas/migrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The rest of this page is a step-by-step beginner's guide for using migrations. C

Let's assume you've just completed your first EF Core application, which contains the following simple model:

```c#
```csharp
public class Blog
{
public int Id { get; set; }
Expand Down Expand Up @@ -49,7 +49,7 @@ dotnet ef migrations add InitialCreate

#### [Visual Studio](#tab/vs)

``` powershell
```powershell
Add-Migration InitialCreate
```

Expand All @@ -68,7 +68,7 @@ dotnet ef database update
```
#### [Visual Studio](#tab/vs)

``` powershell
```powershell
Update-Database
```

Expand All @@ -80,7 +80,7 @@ That's all there is to it - your application is ready to run on your new databas

A few days have passed, and you're asked to add a creation timestamp to your blogs. You've done the necessary changes to your application, and your model now looks like this:

```c#
```csharp
public class Blog
{
public int Id { get; set; }
Expand All @@ -99,7 +99,7 @@ dotnet ef migrations add AddBlogCreatedTimestamp

#### [Visual Studio](#tab/vs)

``` powershell
```powershell
Add-Migration AddBlogCreatedTimestamp
```

Expand All @@ -118,7 +118,7 @@ dotnet ef database update
```
#### [Visual Studio](#tab/vs)

``` powershell
```powershell
Update-Database
```

Expand Down
16 changes: 8 additions & 8 deletions entity-framework/core/managing-schemas/migrations/managing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dotnet ef migrations add AddBlogCreatedTimestamp

### [Visual Studio](#tab/vs)

``` powershell
```powershell
Add-Migration AddBlogCreatedTimestamp
```

Expand Down Expand Up @@ -52,7 +52,7 @@ dotnet ef migrations add InitialCreate --namespace Your.Namespace

### [Visual Studio](#tab/vs)

``` powershell
```powershell
Add-Migration InitialCreate -Namespace Your.Namespace
```

Expand All @@ -66,7 +66,7 @@ While EF Core generally creates accurate migrations, you should always review th

One notable example where customizing migrations is required is when renaming a property. For example, if you rename a property from `Name` to `FullName`, EF Core will generate the following migration:

```c#
```csharp
migrationBuilder.DropColumn(
name: "Name",
table: "Customers");
Expand All @@ -79,7 +79,7 @@ migrationBuilder.AddColumn<string>(

EF Core is generally unable to know when the intention is to drop a column and create a new one (two separate changes), and when a column should be renamed. If the above migration is applied as-is, all your customer names will be lost. To rename a column, replace the above generated migration with the following:

```c#
```csharp
migrationBuilder.RenameColumn(
name: "Name",
table: "Customers",
Expand All @@ -93,7 +93,7 @@ migrationBuilder.RenameColumn(

While renaming a column can be achieved via a built-in API, in many cases that is not possible. For example, we may want to replace existing `FirstName` and `LastName` properties with a single, new `FullName` property. The migration generated by EF Core will be the following:

``` csharp
```csharp
migrationBuilder.DropColumn(
name: "FirstName",
table: "Customer");
Expand All @@ -110,7 +110,7 @@ migrationBuilder.AddColumn<string>(

As before, this would cause unwanted data loss. To transfer the data from the old columns, we rearrange the migrations and introduce a raw SQL operation as follows:

``` csharp
```csharp
migrationBuilder.AddColumn<string>(
name: "FullName",
table: "Customer",
Expand All @@ -137,7 +137,7 @@ Raw SQL can also be used to manage database objects that EF Core isn't aware of.

For example, the following migration creates a SQL Server stored procedure:

```c#
```csharp
migrationBuilder.Sql(
@"
EXEC ('CREATE PROCEDURE getFullName
Expand Down Expand Up @@ -171,7 +171,7 @@ dotnet ef migrations remove

### [Visual Studio](#tab/vs)

``` powershell
```powershell
Remove-Migration
```

Expand Down
14 changes: 7 additions & 7 deletions entity-framework/core/managing-schemas/migrations/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ The MigrationBuilder API allows you to perform many different kinds of operation

To illustrate, let's look at implementing an operation that creates a database user using each approach. In our migrations, we want to enable writing the following code:

``` csharp
```csharp
migrationBuilder.CreateUser("SQLUser1", "Password");
```

## Using MigrationBuilder.Sql()

The easiest way to implement a custom operation is to define an extension method that calls `MigrationBuilder.Sql()`. Here is an example that generates the appropriate Transact-SQL.

``` csharp
```csharp
static MigrationBuilder CreateUser(
this MigrationBuilder migrationBuilder,
string name,
Expand All @@ -29,7 +29,7 @@ static MigrationBuilder CreateUser(

If your migrations need to support multiple database providers, you can use the `MigrationBuilder.ActiveProvider` property. Here's an example supporting both Microsoft SQL Server and PostgreSQL.

``` csharp
```csharp
static MigrationBuilder CreateUser(
this MigrationBuilder migrationBuilder,
string name,
Expand All @@ -56,7 +56,7 @@ This approach only works if you know every provider where your custom operation

To decouple the custom operation from the SQL, you can define your own `MigrationOperation` to represent it. The operation is then passed to the provider so it can determine the appropriate SQL to generate.

``` csharp
```csharp
class CreateUserOperation : MigrationOperation
{
public string Name { get; set; }
Expand All @@ -66,7 +66,7 @@ class CreateUserOperation : MigrationOperation

With this approach, the extension method just needs to add one of these operations to `MigrationBuilder.Operations`.

``` csharp
```csharp
static MigrationBuilder CreateUser(
this MigrationBuilder migrationBuilder,
string name,
Expand All @@ -85,7 +85,7 @@ static MigrationBuilder CreateUser(

This approach requires each provider to know how to generate SQL for this operation in their `IMigrationsSqlGenerator` service. Here is an example overriding the SQL Server's generator to handle the new operation.

``` csharp
```csharp
class MyMigrationsSqlGenerator : SqlServerMigrationsSqlGenerator
{
public MyMigrationsSqlGenerator(
Expand Down Expand Up @@ -130,7 +130,7 @@ class MyMigrationsSqlGenerator : SqlServerMigrationsSqlGenerator

Replace the default migrations sql generator service with the updated one.

``` csharp
```csharp
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options
.UseSqlServer(connectionString)
Expand Down
6 changes: 3 additions & 3 deletions entity-framework/core/managing-schemas/migrations/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To do this...
4. Configure the migrations assembly:

``` csharp
```csharp
options.UseSqlServer(
connectionString,
x => x.MigrationsAssembly("MyApp.Migrations"));
Expand All @@ -32,7 +32,7 @@ To do this...
5. Add a reference to your migrations assembly from the startup assembly.
* If this causes a circular dependency, update the output path of the class library:

``` xml
```xml
<PropertyGroup>
<OutputPath>..\MyStartupProject\bin\$(Configuration)\</OutputPath>
</PropertyGroup>
Expand All @@ -48,7 +48,7 @@ dotnet ef migrations add NewMigration --project MyApp.Migrations

## [Visual Studio](#tab/vs)

``` powershell
```powershell
Add-Migration NewMigration -Project MyApp.Migrations
```

Expand Down
Loading

0 comments on commit 9c200e6

Please sign in to comment.