We have a database schema with ~200 tables. Model snapshot (Migration.Designer.cs) which is created for each migration is ~20K lines. So, having quite a number of migrations really slows down our build on CI (with ~30 migrations building a solution takes 6 minutes with migrations or 4 minutes without them).
So, to the question: is it safe to delete model snapshots for old migrations (that we know we will never Revert)? Are model snapshots used for anything else except Revert-Migration?
Are model snapshots used for anything else except Revert-Migration?
Yes. There are a few edge cases where it's needed. On SQL Server, those cases are:
So most of the time it's probably safe to delete, but please test that your migrations still work after doing so.
Got the same problem on my current project. Above 400 migraitons and 6m lines of code inside .Designer. Here is how I managed to resolve this problem:
<PropertyGroup> ... <DefaultItemExcludes Condition="'$(Configuration)' == 'Debug' ">$(DefaultItemExcludes);Migrations\**\*.Designer.cs</DefaultItemExcludes> </PropertyGroup>
This way you dont need to reset migration neither delete .Designer files.