C
C#4mo ago
LastExceed

✅ why does efcore maintain `ModelSnapshot.cs` on top of `{MIGRATION}.Designer.cs` ?

if i understand correctly, the former represents the "current" state, whereas the latter represents the state the DB should be in after the given migration was applied, and it is discouraged to manually edit either. but then doesn't that mean ModelSnapshot.cs is expected to always mirror the .Designer.cs of the latest migration? and if so, why bother generating a second file in the first place? can't efcore just look up the latest migration?
3 Replies
Anton
Anton4mo ago
probably because it supports out of order migrations like when you merge two branches that each add a migration
LastExceed
LastExceedOP4mo ago
shouldnt that be fixed during merge resolution? otherwise their snapshots would still be invalid
Anton
Anton4mo ago
i don't know it deep enough to tell you

Did you find this page helpful?