Skip to content
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
20 changes: 13 additions & 7 deletions entity-framework/core/cli/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ Deletes the database.

Options:

| Option | Short | Description |
|:-------------------------|:------------------|:---------------------------------------------------------|
| <nobr>`--force`</nobr> | <nobr>`-f`</nobr> | Don't confirm. |
| <nobr>`--dry-run`</nobr> | | Show which database would be dropped, but don't drop it. |
| Option | Short | Description |
|:------------------------------------------|:------------------|:--------------------------------------------------------------------------------------------------------------------------------|
| <nobr>`--force`</nobr> | <nobr>`-f`</nobr> | Don't confirm. |
| <nobr>`--dry-run`</nobr> | | Show which database would be dropped, but don't drop it. |
| <nobr>`--connection <CONNECTION>`</nobr> | | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. Added in EF Core 11. |

The [common options](#common-options) are listed above.

Expand Down Expand Up @@ -341,12 +342,17 @@ Removes the last migration, rolling back the code changes that were done for the

Options:

| Option | Short | Description |
|:-----------------------|:------------------|:--------------------------------------------------------------------------------|
| <nobr>`--force`</nobr> | <nobr>`-f`</nobr> | Revert the latest migration, rolling back both code and database changes that were done for the latest migration. Continues to roll back only the code changes if an error occurs while connecting to the database. |
| Option | Short | Description |
|:-----------------------------------------|:------------------|:-----------------------------------------------------------------------------------------------------|
| <nobr>`--force`</nobr> | <nobr>`-f`</nobr> | Revert the latest migration, rolling back both code and database changes that were done for the latest migration. Continues to roll back only the code changes if an error occurs while connecting to the database. |
| <nobr>`--connection <CONNECTION>`</nobr> | | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. Added in EF Core 11. |
| <nobr>`--offline`</nobr> | | Remove the migration without connecting to the database. Added in EF Core 11. |

The [common options](#common-options) are listed above.

> [!NOTE]
> The `--offline` and `--force` options cannot be used together, since `--force` requires a database connection to check if the migration has been applied before reverting it.

## `dotnet ef migrations script`

Generates a SQL script from migrations.
Expand Down
18 changes: 12 additions & 6 deletions entity-framework/core/cli/powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ Drops the database.

Parameters:

| Parameter | Description |
|:-----------------------|:---------------------------------------------------------|
| <nobr>`-WhatIf`</nobr> | Show which database would be dropped, but don't drop it. |
| Parameter | Description |
|:------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------|
| <nobr>`-WhatIf`</nobr> | Show which database would be dropped, but don't drop it. |
| <nobr>`-Connection <String>`</nobr> | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. Added in EF Core 11. |

The [common parameters](#common-parameters) are listed above.

Expand Down Expand Up @@ -210,12 +211,17 @@ Removes the last migration (rolls back the code changes that were done for the m

Parameters:

| Parameter | Description |
|:----------------------|:--------------------------------------------------------------------------------|
| <nobr>`-Force`</nobr> | Revert the migration (roll back the changes that were applied to the database). |
| Parameter | Description |
|:------------------------------------|:-------------------------------------------------------------------------------------------------------------|
| <nobr>`-Force`</nobr> | Revert the migration (roll back the changes that were applied to the database). |
| <nobr>`-Connection <String>`</nobr> | The connection string to the database. Defaults to the one specified in `AddDbContext` or `OnConfiguring`. Added in EF Core 11. |
| <nobr>`-Offline`</nobr> | Remove the migration without connecting to the database. Added in EF Core 11. |

The [common parameters](#common-parameters) are listed above.

> [!NOTE]
> The `-Offline` and `-Force` parameters cannot be used together, since `-Force` requires a database connection to check if the migration has been applied before reverting it.

## Scaffold-DbContext

Generates code for a `DbContext` and entity types for a database. In order for `Scaffold-DbContext` to generate an entity type, the database table must have a primary key.
Expand Down
30 changes: 30 additions & 0 deletions entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,36 @@ In PowerShell, use the `-Add` parameter:
Update-Database -Migration InitialCreate -Add
```

<a name="migrations-remove-connection-offline"></a>

### Connection and offline options for migrations remove

The `dotnet ef migrations remove` and `database drop` commands now accept `--connection` parameters, allowing you to specify the database connection string directly without needing to configure a default connection in your `DbContext`. Additionally, `migrations remove` supports the new `--offline` option to remove a migration without connecting to the database:

```console
# Remove migration with specific connection
dotnet ef migrations remove --connection "Server=prod;Database=MyDb;..."

# Remove migration without connecting to database (offline mode)
dotnet ef migrations remove --offline

# Revert and remove applied migration
dotnet ef migrations remove --force

# Drop specific database by connection string
dotnet ef database drop --connection "Server=test;Database=MyDb;..." --force
```

The `--offline` option skips the database connection check entirely, which is useful when the database is inaccessible or when you're certain the migration hasn't been applied. Note that `--offline` and `--force` cannot be used together, since `--force` requires a database connection to check if the migration has been applied before reverting it.

In PowerShell, use the `-Connection` and `-Offline` parameters:

```powershell
Remove-Migration -Connection "Server=prod;Database=MyDb;..."
Remove-Migration -Offline
Drop-Database -Connection "Server=test;Database=MyDb;..." -Force
```

## SQL Server

<a name="sqlserver-vector-search"></a>
Expand Down