Entity Framework Core: Is it safe to delete Migration.Designer.cs if we will never Revert a migration?

心不动则不痛 提交于 2019-12-03 13:36:46

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:

  • AlterColumn when the column is narrowed or the computed expression is changed and the indexes need to be rebuilt
  • CreateIndex on a memory-optimized table when the index is unique and references nullable columns

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:

MigrationProject.csproj

  <PropertyGroup>
     ...
     <DefaultItemExcludes Condition="'$(Configuration)' == 'Debug' ">$(DefaultItemExcludes);Migrations\**\*.Designer.cs</DefaultItemExcludes>
  </PropertyGroup>

This way you dont need to reset migration neither delete .Designer files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!