Skip to content

Commit

Permalink
Run docs through markdown linter
Browse files Browse the repository at this point in the history
Added .markdownlint.json to help keep things clean
  • Loading branch information
roji committed Oct 2, 2019
1 parent 6c103b2 commit aec3730
Show file tree
Hide file tree
Showing 53 changed files with 415 additions and 254 deletions.
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MD013": false,
"MD024": false,
"MD025": { "front_matter_title": "" },
"MD028": false,
"MD033": { "allowed_elements": ["sup", "sub"] }
}
6 changes: 3 additions & 3 deletions entity-framework/core/extensions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LLBLGen Pro is an entity modeling solution with support for Entity Framework and

### Devart Entity Developer

Entity Developer is a powerful ORM designer for ADO.NET Entity Framework, NHibernate, LinqConnect, Telerik Data Access, and LINQ to SQL. It supports designing EF Core models visually, using model first or database first approaches, and C# or Visual Basic code generation.
Entity Developer is a powerful ORM designer for ADO.NET Entity Framework, NHibernate, LinqConnect, Telerik Data Access, and LINQ to SQL. It supports designing EF Core models visually, using model first or database first approaches, and C# or Visual Basic code generation.

[Website](https://www.devart.com/entitydeveloper/)

Expand All @@ -47,7 +47,7 @@ CatFactory is a scaffolding engine for .NET Core that can automate the generatio

### LoreSoft's Entity Framework Core Generator

Entity Framework Core Generator (efg) is a .NET Core CLI tool that can generate EF Core models from an existing database, much like `dotnet ef dbcontext scaffold`, but it also supports safe code [regeneration](https://efg.loresoft.com/en/latest/regeneration/) via region replacement or by parsing mapping files. This tool supports generating view models, validation, and object mapper code.
Entity Framework Core Generator (efg) is a .NET Core CLI tool that can generate EF Core models from an existing database, much like `dotnet ef dbcontext scaffold`, but it also supports safe code [regeneration](https://efg.loresoft.com/en/latest/regeneration/) via region replacement or by parsing mapping files. This tool supports generating view models, validation, and object mapper code.

[Tutorial](http://www.loresoft.com/Generate-ASP-NET-Web-API)
[Documentation](https://efg.loresoft.com/en/latest/)
Expand Down Expand Up @@ -81,7 +81,7 @@ This library allows retrieving the values of primary key (including composite ke

### EntityFrameworkCore.TypedOriginalValues

This library enables strongly typed access to the original values of entity properties.
This library enables strongly typed access to the original values of entity properties.

[GitHub repository](https://github.com/NickStrupat/EntityFramework.TypedOriginalValues/)

Expand Down
22 changes: 11 additions & 11 deletions entity-framework/core/get-started/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uid: core/get-started/install/index

## Prerequisites

* EF Core is a [.NET Standard 2.1](/dotnet/standard/net-standard) library. So EF Core requires a .NET implementation that supports .NET Standard 2.1 to run. EF Core can also be referenced by other .NET Standard 2.1 libraries.
* EF Core is a [.NET Standard 2.1](/dotnet/standard/net-standard) library. So EF Core requires a .NET implementation that supports .NET Standard 2.1 to run. EF Core can also be referenced by other .NET Standard 2.1 libraries.

* For example, you can use EF Core to develop apps that target .NET Core. Building .NET Core apps requires the [.NET Core SDK](https://dotnet.microsoft.com/download). Optionally, you can also use a development environment like [Visual Studio](https://visualstudio.microsoft.com/vs), [Visual Studio for Mac](https://visualstudio.microsoft.com/vs/mac), or [Visual Studio Code](https://code.visualstudio.com). For more information, check [Getting Started with .NET Core](/dotnet/core/get-started).

Expand Down Expand Up @@ -58,6 +58,7 @@ For more information, see [NuGet Package Manager Dialog](/nuget/tools/package-ma
``` PowerShell
Install-Package Microsoft.EntityFrameworkCore.SqlServer
```

* To update the provider, use the `Update-Package` command.

* To specify a specific version, use the `-Version` modifier. For example, to install EF Core 2.2.0 packages, append `-Version 2.2.0` to the commands
Expand All @@ -70,7 +71,7 @@ You can install tools to carry out EF Core-related tasks in your project, like c

Two sets of tools are available:

* The [.NET Core command-line interface (CLI) tools](xref:core/miscellaneous/cli/dotnet) can be used on Windows, Linux, or macOS. These commands begin with `dotnet ef`.
* The [.NET Core command-line interface (CLI) tools](xref:core/miscellaneous/cli/dotnet) can be used on Windows, Linux, or macOS. These commands begin with `dotnet ef`.

* The [Package Manager Console (PMC) tools](xref:core/miscellaneous/cli/powershell) run in Visual Studio on Windows. These commands start with a verb, for example `Add-Migration`, `Update-Database`.

Expand All @@ -88,28 +89,28 @@ Although you can also use the `dotnet ef` commands from the Package Manager Cons

The `dotnet ef` commands are included in current versions of the .NET Core SDK, but to enable the commands on a specific project, you have to install the `Microsoft.EntityFrameworkCore.Design` package:

``` Console
dotnet add package Microsoft.EntityFrameworkCore.Design
```
``` Console
dotnet add package Microsoft.EntityFrameworkCore.Design
```

For ASP.NET Core apps, this package is included automatically.

> [!IMPORTANT]
> [!IMPORTANT]
> Always use the version of the tools package that matches the major version of the runtime packages.
### Get the Package Manager Console tools

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
```
```

For ASP.NET Core apps, this package is included automatically.

## Upgrading to the latest EF Core

* Any time we release a new version of EF Core, we also release a new version of the providers that are part of the EF Core project, like Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Sqlite, and Microsoft.EntityFrameworkCore.InMemory. You can just upgrade to the new version of the provider to get all the improvements.
* Any time we release a new version of EF Core, we also release a new version of the providers that are part of the EF Core project, like Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.Sqlite, and Microsoft.EntityFrameworkCore.InMemory. You can just upgrade to the new version of the provider to get all the improvements.

* EF Core, together with the SQL Server and the in-memory providers are included in current versions of ASP.NET Core. To upgrade an existing ASP.NET Core application to a newer version of EF Core, always upgrade the version of ASP.NET Core.

Expand All @@ -123,7 +124,6 @@ For ASP.NET Core apps, this package is included automatically.

* The .NET CLI tools are included in the .NET SDK since version 2.1, so the reference to that package can be removed from the project file:

```
``` xml
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
```

1 change: 1 addition & 0 deletions entity-framework/core/managing-schemas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ author: bricelam
ms.date: 10/30/2017
---
# Managing Database Schemas

EF Core provides two primary ways of keeping your EF Core model and database schema in sync. To choose between the two,
decide whether your EF Core model or the database schema is the source of truth.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ author: bricelam
ms.author: bricelam
ms.date: 11/07/2017
---
Custom Migrations History Table
===============================
# Custom Migrations History Table

By default, EF Core keeps track of which migrations have been applied to the database by recording them in a table named
`__EFMigrationsHistory`. For various reasons, you may want to customize this table to better suit your needs.

> [!IMPORTANT]
> If you customize the Migrations history table *after* applying migrations, you are responsible for updating the
> existing table in the database.
Schema and table name
----------------------
## Schema and table name

You can change the schema and table name using the `MigrationsHistoryTable()` method in `OnConfiguring()` (or
`ConfigureServices()` on ASP.NET Core). Here is an example using the SQL Server EF Core provider.

Expand All @@ -25,8 +25,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder options)
x => x.MigrationsHistoryTable("__MyMigrationsHistory", "mySchema"));
```

Other changes
-------------
## Other changes

To configure additional aspects of the table, override and replace the provider-specific
`IHistoryRepository` service. Here is an example of changing the MigrationId column name to *Id* on SQL Server.

Expand Down
126 changes: 85 additions & 41 deletions entity-framework/core/managing-schemas/migrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ ms.author: bricelam
ms.date: 10/05/2018
uid: core/managing-schemas/migrations/index
---
Migrations
==========
# Migrations

A data model changes during development and gets out of sync with the database. You can drop the database and let EF create a new one that matches the model, but this procedure results in the loss of data. The migrations feature in EF Core provides a way to incrementally update the database schema to keep it in sync with the application's data model while preserving existing data in the database.

Expand All @@ -23,24 +22,30 @@ Migrations includes command-line tools and APIs that help with the following tas
> [!TIP]
> If the `DbContext` is in a different assembly than the startup project, you can explicitly specify the target and startup projects in either the [Package Manager Console tools](xref:core/miscellaneous/cli/powershell#target-and-startup-project) or the [.NET Core CLI tools](xref:core/miscellaneous/cli/dotnet#target-project-and-startup-project).
Install the tools
-----------------
## Install the tools

Install the [command-line tools](xref:core/miscellaneous/cli/index):

* For Visual Studio, we recommend the [Package Manager Console tools](xref:core/miscellaneous/cli/powershell).
* For other development environments, choose the [.NET Core CLI tools](xref:core/miscellaneous/cli/dotnet).

Create a migration
------------------
## Create a migration

After you've [defined your initial model](xref:core/modeling/index), it's time to create the database. To add an initial migration, run the following command.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef migrations add InitialCreate
```

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

``` powershell
Add-Migration InitialCreate
```
``` Console
dotnet ef migrations add InitialCreate
```

***

Three files are added to your project under the **Migrations** directory:

Expand All @@ -56,29 +61,41 @@ The timestamp in the filename helps keep them ordered chronologically so you can
> You are free to move Migrations files and change their namespace. New migrations are created as siblings of the last
> migration.
Update the database
-------------------
## Update the database

Next, apply the migration to the database to create the schema.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef database update
```

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

``` powershell
Update-Database
```
``` Console
dotnet ef database update
```

Customize migration code
------------------------
***

## Customize migration code

After making changes to your EF Core model, the database schema might be out of sync. To bring it up to date, add another migration. The migration name can be used like a commit message in a version control system. For example, you might choose a name like *AddProductReviews* if the change is a new entity class for reviews.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef migrations add AddProductReviews
```

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

``` powershell
Add-Migration AddProductReviews
```
``` Console
dotnet ef migrations add AddProductReviews
```

***

Once the migration is scaffolded (code generated for it), review the code for accuracy and add, remove or modify any operations required to apply it correctly.

Expand Down Expand Up @@ -127,12 +144,19 @@ migrationBuilder.DropColumn(
Apply the migration to the database using the appropriate command.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef database update
```

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

``` powershell
Update-Database
```
``` Console
dotnet ef database update
```

***

### Empty migrations

Expand All @@ -144,40 +168,61 @@ Sometimes it's useful to add a migration without making any model changes. In th
* Triggers
* Views

Remove a migration
------------------
## Remove a migration

Sometimes you add a migration and realize you need to make additional changes to your EF Core model before applying it. To remove the last migration, use this command.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef migrations remove
```

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

``` powershell
Remove-Migration
```
``` Console
dotnet ef migrations remove
```

***

After removing the migration, you can make the additional model changes and add it again.

Revert a migration
------------------
## Revert a migration

If you already applied a migration (or several migrations) to the database but need to revert it, you can use the same command to apply migrations, but specify the name of the migration you want to roll back to.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef database update LastGoodMigration
```

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

``` powershell
Update-Database LastGoodMigration
```
``` Console
dotnet ef database update LastGoodMigration
```

Generate SQL scripts
--------------------
***

## Generate SQL scripts

When debugging your migrations or deploying them to a production database, it's useful to generate a SQL script. The script can then be further reviewed for accuracy and tuned to fit the needs of a production database. The script can also be used in conjunction with a deployment technology. The basic command is as follows.

## [.NET Core CLI](#tab/dotnet-core-cli)

``` console
dotnet ef migrations script
```

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

``` powershell
Script-Migration
```
``` Console
dotnet ef migrations script
```

***

There are several options to this command.

Expand All @@ -187,8 +232,8 @@ The **to** migration is the last migration that will be applied to the database

An **idempotent** script can optionally be generated. This script only applies migrations if they haven't already been applied to the database. This is useful if you don't exactly know what the last migration applied to the database was or if you are deploying to multiple databases that may each be at a different migration.

Apply migrations at runtime
---------------------------
## Apply migrations at runtime

Some apps may want to apply migrations at runtime during startup or first run. Do this using the `Migrate()` method.

This method builds on top of the `IMigrator` service, which can be used for more advanced scenarios. Use `myDbContext.GetInfrastructure().GetService<IMigrator>()` to access it.
Expand All @@ -201,7 +246,6 @@ myDbContext.Database.Migrate();
> * This approach isn't for everyone. While it's great for apps with a local database, most applications will require more robust deployment strategy like generating SQL scripts.
> * Don't call `EnsureCreated()` before `Migrate()`. `EnsureCreated()` bypasses Migrations to create the schema, which causes `Migrate()` to fail.
Next steps
----------
## Next steps

For more information, see <xref:core/miscellaneous/cli/index>.
12 changes: 6 additions & 6 deletions entity-framework/core/managing-schemas/migrations/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ms.author: bricelam
ms.date: 11/07/2017
uid: core/managing-schemas/migrations/operations
---
Custom Migrations Operations
============================
# Custom Migrations Operations

The MigrationBuilder API allows you to perform many different kinds of operations during a migration, but it's far from
exhaustive. However, the API is also extensible allowing you to define your own operations. There are two ways to extend
the API: Using the `Sql()` method, or by defining custom `MigrationOperation` objects.
Expand All @@ -18,8 +18,8 @@ migrations, we want to enable writing the following code:
migrationBuilder.CreateUser("SQLUser1", "Password");
```

Using MigrationBuilder.Sql()
----------------------------
## 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.

Expand Down Expand Up @@ -57,8 +57,8 @@ static MigrationBuilder CreateUser(

This approach only works if you know every provider where your custom operation will be applied.

Using a MigrationOperation
---------------------------
## Using a MigrationOperation

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.

Expand Down
Loading

0 comments on commit aec3730

Please sign in to comment.