dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.59k stars 1.95k forks source link

Please be clearer about the meaning of the <MigrationTimestamp>_<MigrationName>.Designer.cs file #1868

Open jimmcslim opened 4 years ago

jimmcslim commented 4 years ago

While this page describes the different files involved in an EF Core migration, it could be clearer about each of their roles. For example, what is the difference between the <ContextName>Snapshot.cs file and each <MigrationTimestamp>_<MigrationName>.Designer.cs file? What does EF Core use each of these files for? Convention suggests that we should keep our hands off the Designer.cs file, whereas it isn't as clear as to whether we can safely edit the Snapshot.cs file (although I don't).


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

bricelam commented 4 years ago

Designer file: https://stackoverflow.com/a/47060795/475031 Snapshot: https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/teams

ravindUwU commented 1 month ago

Agreed! https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/managing describes these as "metadata files that contain information used by EF", which is kinda vague and unhelpful 😬.

I think some user-oriented documentation that describes what the designer files are, their purpose, implications of removing them (on the ability to roll back migrations, for example), etc. might be useful.


At a quick glance, both the DB snapshot & the migration designer files seem to use the same Microsoft.EntityFrameworkCore.ModelBuilder APIs to capture a snapshot of the DB; except the former represents the state of the DB after all migrations are applied, and the latter, the state after the corresponding migration is applied.

Does the designer file contain any metadata that isn't available in the migration file? I see the primary key names, foreign key names, index names, in both 👀.


Edit: The links in Brice's comment above (which I didn't notice earlier) sheds some light on this 🎉 but the EF docs are still lacking in this area; so I'll keep this comment up 😅.