Repository navigation
Update migrations.md - #5807
Update migrations.md#5807
Conversation
| 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. |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
+1 Maybe something like...
When deleting a migration, use the
dotnet ef migrations removecommand. This ensures the snapshot is also correctly reset.
| ## 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*. |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
...more information about how the snapshot file is used.
|
@tdykstra can you take another look |
Fixes #5801
Review URL
@bricelam once these changes are approved, I'll apply them to the Razor Pages version