Skip to content
Open
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
5 changes: 5 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
"redirect_url": "/ef/ef6/what-is-new/index",
"redirect_document_id": false
},
{
"source_path": "entity-framework/ef6/modeling/code-first/migrations/migrate-exe.md",
"redirect_url": "/ef/ef6/modeling/code-first/migrations/ef6-exe",
"redirect_document_id": true
},
{
"source_path": "entity-framework/core/get-started/aspnetcore/existing-db.md",
"redirect_url": "/aspnet/core/data/ef-rp/intro",
Expand Down
101 changes: 101 additions & 0 deletions entity-framework/ef6/modeling/code-first/migrations/ef6-exe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
title: Using ef6.exe - EF6
description: Using ef6.exe in Entity Framework 6
author: SamMonoRT
ms.date: 08/19/2026
uid: ef6/modeling/code-first/migrations/ef6-exe
---
# Using ef6.exe

> [!NOTE]
> This article assumes you know how to use Code First Migrations in basic scenarios. If you don't, then read [Code First Migrations](xref:ef6/modeling/code-first/migrations/index) before continuing.

Code First Migrations can update a database from Visual Studio, but you can also run migrations from the command line with `ef6.exe`. This utility replaces `migrate.exe`.

## Locate ef6.exe

When you install Entity Framework using NuGet, `ef6.exe` is in the tools folder of the NuGet package. With PackageReference, the package is stored in the global packages folder. For example:

```text
%USERPROFILE%\.nuget\packages\entityframework\6.4.4\tools\net45\win-x86\ef6.exe
```

Replace `6.4.4` with the version of Entity Framework installed in your project.

## View the options

```console
ef6.exe database update --help
```

## Migrate to the latest migration

```console
ef6.exe database update --assembly MyMvcApplication.dll --config ..\web.config
```

The assembly containing the migrations is required. Other settings use conventions when they aren't specified.

## Migrate to a specific migration

```console
ef6.exe database update --assembly MyApp.exe --config MyApp.exe.config --target AddTitle
```

Use `--target` to apply all migrations through a specific migration.

## Specify working directory

```console
ef6.exe database update --assembly MyApp.exe --config MyApp.exe.config --project-dir C:\MyApp
```

Use `--project-dir` when the assembly has dependencies or reads files relative to the project directory.

## Specify migration configuration to use

```console
ef6.exe database update --assembly MyAssembly.dll --migrations-config CustomConfig --config ..\web.config
```

If the assembly contains multiple migration configuration classes, use `--migrations-config` to specify which one to use.

## Provide connection string

```console
ef6.exe database update --assembly BlogDemo.dll --connection-string "Data Source=localhost;Initial Catalog=BlogDemo;Integrated Security=SSPI" --connection-provider System.Data.SqlClient
```

When you specify a connection string, you must also specify its provider name.

## Generate a SQL script

Use `--script` to write the SQL migration script to standard output. Redirect the output to save the script to a file:

```console
ef6.exe database update --assembly MyApp.dll --script > migration.sql
```

Use `--source` and `--target` to control the range of migrations included in the script.

## migrate.exe option equivalents

The following table maps `migrate.exe` arguments to their `ef6.exe database update` equivalents:

| migrate.exe | ef6.exe database update |
| --- | --- |
| `<assembly>` | `--assembly` |
| `<configurationType>` | `--migrations-config` |
| `<contextAssembly>` | No equivalent. Put it in the same directory as the assembly passed to `--assembly`. |
| `/targetMigration` | `--target` |
| `/startUpDirectory` | `--project-dir` |
| `/scriptFile` | `--script` |
| `/sourceMigration` | `--source` |
| `/startUpConfigurationFile` | `--config` |
| `/startUpDataDirectory` | `--data-dir` |
Comment on lines +91 to +95
| `/connectionStringName` | `--connection-string-name` |
| `/connectionString` | `--connection-string` |
| `/connectionProviderName` | `--connection-provider` |
| `/force` | `--force` |
| `/verbose` | `--verbose` |
| `/?` | `--help` |
91 changes: 0 additions & 91 deletions entity-framework/ef6/modeling/code-first/migrations/migrate-exe.md

This file was deleted.

2 changes: 1 addition & 1 deletion entity-framework/ef6/what-is-new/past-releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Here is a list of content we put together specifically for the EF 5 release:
- [Fluent API with VB.NET](xref:ef6/modeling/code-first/fluent/vb)
- [Code First Migrations](xref:ef6/modeling/code-first/migrations/index)
- [Automatic Code First Migrations](xref:ef6/modeling/code-first/migrations/automatic)
- [Migrate.exe](xref:ef6/modeling/code-first/migrations/migrate-exe)
- [ef6.exe](xref:ef6/modeling/code-first/migrations/ef6-exe)
- [Defining DbSets](xref:ef6/modeling/code-first/dbsets)
- EF Designer
- [Model First (walkthrough and video)](xref:ef6/modeling/designer/workflows/model-first)
Expand Down
4 changes: 2 additions & 2 deletions entity-framework/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@
href: ef6/modeling/code-first/migrations/existing-database.md
- name: Customize Migrations history
href: ef6/modeling/code-first/migrations/history-customization.md
- name: Use Migrate.exe
href: ef6/modeling/code-first/migrations/migrate-exe.md
- name: Use ef6.exe
href: ef6/modeling/code-first/migrations/ef6-exe.md
Comment on lines +639 to +640
- name: Migrations in team environments
href: ef6/modeling/code-first/migrations/teams.md
- name: Use EF Designer
Expand Down