Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify how to use Connection in Update-Database. #2338

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is still not quite same as other tables in this page.



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