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 23, 2019
1 parent f0a2852 commit eab3101
Show file tree
Hide file tree
Showing 46 changed files with 401 additions and 188 deletions.
6 changes: 6 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": true,
"MD013": false,
"MD025": { "front_matter_title": "" },
"MD033": { "allowed_elements": ["sup", "sub", "nobe"] }
}
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](https://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
23 changes: 12 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 @@ -122,7 +123,7 @@ For ASP.NET Core apps, this package is included automatically.
* Database provider design-time packages such as `Microsoft.EntityFrameworkCore.SqlServer.Design` are no longer required or supported from EF Core 2.0 and later, but aren't automatically removed when upgrading the other packages.

* 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

``` 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 @@ -5,7 +5,6 @@ ms.author: bricelam
ms.date: 11/07/2017
uid: core/managing-schemas/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
Expand Down
84 changes: 63 additions & 21 deletions entity-framework/core/managing-schemas/migrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ Install the [command-line tools](xref:core/miscellaneous/cli/index):

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.

``` powershell
Add-Migration InitialCreate
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations add InitialCreate
```

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

``` powershell
Add-Migration InitialCreate
```

***

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

* **XXXXXXXXXXXXXX_InitialCreate.cs**--The main migrations file. Contains the operations necessary to apply the migration (in `Up()`) and to revert it (in `Down()`).
Expand All @@ -56,26 +62,38 @@ The timestamp in the filename helps keep them ordered chronologically so you can

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

``` powershell
Update-Database
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef database update
```

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

``` powershell
Update-Database
```

***

## 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.

``` powershell
Add-Migration AddProductReviews
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations add AddProductReviews
```

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

``` powershell
Add-Migration 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.

For example, a migration might contain the following operations:
Expand Down Expand Up @@ -123,14 +141,20 @@ migrationBuilder.DropColumn(
Apply the migration to the database using the appropriate command.

``` powershell
Update-Database
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef database update
```

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

``` powershell
Update-Database
```

***

### Empty migrations

Sometimes it's useful to add a migration without making any model changes. In this case, adding a new migration creates code files with empty classes. You can customize this migration to perform operations that don't directly relate to the EF Core model. Some things you might want to manage this way are:
Expand All @@ -145,40 +169,58 @@ Sometimes it's useful to add a migration without making any model changes. In th

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.

``` powershell
Remove-Migration
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations remove
```

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

``` powershell
Remove-Migration
```

***

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

## 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.

``` powershell
Update-Database LastGoodMigration
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef database update LastGoodMigration
```

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

``` powershell
Update-Database LastGoodMigration
```

***

## 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.

``` powershell
Script-Migration
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations script
```

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

``` powershell
Script-Migration
```

***

There are several options to this command.

The **from** migration should be the last migration applied to the database before running the script. If no migrations have been applied, specify `0` (this is the default).
Expand Down
12 changes: 9 additions & 3 deletions entity-framework/core/managing-schemas/migrations/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ To do this...

If you did everything correctly, you should be able to add new migrations to the project.

``` powershell
Add-Migration NewMigration -Project MyApp.Migrations
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations add NewMigration --project MyApp.Migrations
```

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

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

***
14 changes: 10 additions & 4 deletions entity-framework/core/managing-schemas/migrations/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,22 @@ class MySqliteDbContext : MyDbContext
When adding new migration, specify the context types.

``` powershell
Add-Migration InitialCreate -Context MyDbContext -OutputDir Migrations\SqlServerMigrations
Add-Migration InitialCreate -Context MySqliteDbContext -OutputDir Migrations\SqliteMigrations
```
## [.NET Core CLI](#tab/dotnet-core-cli)

``` Console
dotnet ef migrations add InitialCreate --context MyDbContext --output-dir Migrations/SqlServerMigrations
dotnet ef migrations add InitialCreate --context MySqliteDbContext --output-dir Migrations/SqliteMigrations
```

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

``` powershell
Add-Migration InitialCreate -Context MyDbContext -OutputDir Migrations\SqlServerMigrations
Add-Migration InitialCreate -Context MySqliteDbContext -OutputDir Migrations\SqliteMigrations
```

***

> [!TIP]
> You don't need to specify the output directory for subsequent migrations since they are created as siblings to the
> last one.
Expand Down
24 changes: 14 additions & 10 deletions entity-framework/core/managing-schemas/migrations/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ migration before sharing it.

When you merge migrations from your teammates, you may get conflicts in your model snapshot file. If both changes are unrelated, the merge is trivial and the two migrations can coexist. For example, you may get a merge conflict in the customer entity type configuration that looks like this:

<<<<<<< Mine
b.Property<bool>("Deactivated");
=======
b.Property<int>("LoyaltyPoints");
>>>>>>> Theirs
``` output
<<<<<<< Mine
b.Property<bool>("Deactivated");
=======
b.Property<int>("LoyaltyPoints");
>>>>>>> Theirs
```

Since both of these properties need to exist in the final model, complete the merge by adding both properties. In many
cases, your version control system may automatically merge such changes for you.
Expand All @@ -34,11 +36,13 @@ In these cases, your migration and your teammate's migration are independent of

Sometimes you encounter a true conflict when merging the model snapshot model. For example, you and your teammate may each have renamed the same property.

<<<<<<< Mine
b.Property<string>("Username");
=======
b.Property<string>("Alias");
>>>>>>> Theirs
``` output
<<<<<<< Mine
b.Property<string>("Username");
=======
b.Property<string>("Alias");
>>>>>>> Theirs
```

If you encounter this kind of conflict, resolve it by re-creating your migration. Follow these steps:

Expand Down
Loading

0 comments on commit eab3101

Please sign in to comment.