Skip to content

Commit

Permalink
Specify how to use Connection in Update-Database. (#2338)
Browse files Browse the repository at this point in the history
  • Loading branch information
lajones committed Apr 29, 2020
1 parent 4c85317 commit 799c147
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 9 additions & 2 deletions entity-framework/core/miscellaneous/cli/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,18 @@ Arguments:
|:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<MIGRATION>` | The target migration. Migrations may be identified by name or by ID. The number 0 is a special case that means *before the first migration* and causes all migrations to be reverted. If no migration is specified, the command defaults to the last migration. |

The following examples update the database to a specified migration. The first uses the migration name and the second uses the migration ID:
Options:

| | Option | Description |
|:------------------|:-------------------------|:---------------------------------------------------------|
| <nobr> </nobr> | `--connection <CONNECTION>` | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. |


The following examples update the database to a specified migration. The first uses the migration name and the second uses the migration ID and a specified connection:

```dotnetcli
dotnet ef database update InitialCreate
dotnet ef database update 20180904195021_InitialCreate
dotnet ef database update 20180904195021_InitialCreate --connection your_connection_string
```

## dotnet ef dbcontext info
Expand Down
7 changes: 4 additions & 3 deletions entity-framework/core/miscellaneous/cli/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ The following table shows parameters that are common to all of the EF Core comma
|:--------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| -Context \<String> | The `DbContext` class to use. Class name only or fully qualified with namespaces. If this parameter is omitted, EF Core finds the context class. If there are multiple context classes, this parameter is required. |
| -Project \<String> | The target project. If this parameter is omitted, the **Default project** for **Package Manager Console** is used as the target project. |
| -StartupProject \<String> | The startup project. If this parameter is omitted, the **Startup project** in **Solution properties** is used as the target project. |
| <nobr>-StartupProject</nobr> \<String> | The startup project. If this parameter is omitted, the **Startup project** in **Solution properties** is used as the target project. |
| -Verbose | Show verbose output. |

To show help information about a command, use PowerShell's `Get-Help` command.
Expand Down Expand Up @@ -241,6 +241,7 @@ Updates the database to the last migration or to a specified migration.
| Parameter | Description |
|:------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| <nobr>*-Migration* \<String></nobr> | The target migration. Migrations may be identified by name or by ID. The number 0 is a special case that means *before the first migration* and causes all migrations to be reverted. If no migration is specified, the command defaults to the last migration. |
| <nobr>-Connection \<String></nobr> | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. |

> [!TIP]
> The Migration parameter supports tab-expansion.
Expand All @@ -251,11 +252,11 @@ The following example reverts all migrations.
Update-Database -Migration 0
```

The following examples update the database to a specified migration. The first uses the migration name and the second uses the migration ID:
The following examples update the database to a specified migration. The first uses the migration name and the second uses the migration ID and a specified connection:

```powershell
Update-Database -Migration InitialCreate
Update-Database -Migration 20180904195021_InitialCreate
Update-Database -Migration 20180904195021_InitialCreate -Connection your_connection_string
```

## Additional resources
Expand Down

0 comments on commit 799c147

Please sign in to comment.