Skip to content

Update migrations.md - #5807

Merged
Rick-Anderson merged 3 commits into
masterfrom
Rick-Anderson-patch-1
Mar 27, 2018
Merged

Rick-Anderson merged 3 commits into
masterfrom
Rick-Anderson-patch-1

Conversation

@Rick-Anderson

@Rick-Anderson Rick-Anderson commented Mar 27, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #5801
Review URL

@bricelam once these changes are approved, I'll apply them to the Razor Pages version

Comment thread aspnetcore/data/ef-mvc/migrations.md Outdated
Migrations creates a *snapshot* of the current database schema in *Migrations/SchoolContextModelSnapshot.cs*.

[!code-csharp[](intro/samples/cu/Migrations/SchoolContextModelSnapshot1.cs?name=snippet_Truncate)]
To delete a migration, use the [dotnet ef migrations remove](https://docs.microsoft.com/ef/core/miscellaneous/cli/dotnet#dotnet-ef-migrations-remove) command.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Without the sentence that begins "The snapshot file has to be kept in sync..." to introduce this sentence, this sentence doesn't make a lot of sense here because it won't be clear why we're talking about deleting a migration in a section titled "The data model snapshot".

@bricelam bricelam Mar 27, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 Maybe something like...

When deleting a migration, use the dotnet ef migrations remove command. This ensures the snapshot is also correctly reset.

Comment thread aspnetcore/data/ef-mvc/migrations.md Outdated
## The data model snapshot

Migrations also creates a *snapshot* of the current database schema in *Migrations/SchoolContextModelSnapshot.cs*. Here's what that code looks like:
Migrations creates a *snapshot* of the current database schema in *Migrations/SchoolContextModelSnapshot.cs*.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this sentence should stay too:

When you add a migration, EF determines what changed by comparing the data model to the snapshot file.

Comment thread aspnetcore/data/ef-mvc/migrations.md Outdated
Because the current database schema is represented in code, EF Core doesn't have to interact with the database to create migrations. When you add a migration, EF determines what changed by comparing the data model to the snapshot file. EF interacts with the database only when it has to update the database.

The snapshot file has to be kept in sync with the migrations that create it, so you can't remove a migration just by deleting the file named *\<timestamp>_\<migrationname>.cs*. If you delete that file, the remaining migrations will be out of sync with the database snapshot file. To delete the last migration that you added, use the [dotnet ef migrations remove](https://docs.microsoft.com/ef/core/miscellaneous/cli/dotnet#dotnet-ef-migrations-remove) command.
See [EF Core Migrations in Team Environments](/ef/core/managing-schemas/migrations/teams) for more information.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

...more information about how the snapshot file is used.

@Rick-Anderson

Copy link
Copy Markdown
Contributor Author

@tdykstra can you take another look

@bricelam bricelam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Rick-Anderson
Rick-Anderson merged commit cace363 into master Mar 27, 2018
@Rick-Anderson
Rick-Anderson deleted the Rick-Anderson-patch-1 branch March 27, 2018 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants