本文介绍了如何处理庞大的efcore迁移设计器文件,这会减慢构建和IDE的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个efcore 2.1项目,其中包含约230个实体和约350个迁移.每次添加efcore迁移时,都会创建一个设计器文件.该文件约为535 kb,并且正在增长(对于alle Designer文件,总数为150mb).这使IDE变慢且无响应,重构是不可行的,也使构建过程变慢.如果删除所有设计器文件,则构建时间将从110秒降低到20秒,IDE再次变得灵活.

I currently have an efcore 2.1 project with about 230 entities and about 350 migrations. Every time i add an efcore migration, a designer file is created. This file is approximately 535 kb and growing (150mb total for alle designer files). This makes the IDE slow and unresponsive, refactoring is a no go, it also makes the build process slower. If i delete all designer files, the build goes down from 110 to 20 seconds, and the IDE gets snappy again.

但是,一旦删除所有设计器文件,我将无法使用"dotnet ef database"命令.

however, once I delete all designer files, i'm not able to work with the "dotnet ef database" command.

我以前也合并了所有迁移.这是可行的,但是在团队设置中有一些问题(必须在每台开发人员机器上运行手动命令,没有团队成员可以进行任何未同步的迁移等),并且只是暂时的,因为迁移会在一段时间后再次开始堆积

I have also previously merged all migrations. this worked, except there were some issues doing this in a team setting (had to run manual commands on each developer machine, no team members could have any unsynced migrations etc) and it is only temporary as the migrations start piling up again after a while.

我很好奇是否还有其他存在相同问题的项目,以及它们如何解决?

I am curious if there are other projects with the same problem, and how they work around this?

推荐答案

现在,将来可以在 Migrations 文件夹中添加 .editorconfig 文件,具有以下内容:

Now, in the future, it's possible to add an .editorconfig file to the Migrations folder, with the following contents:

# All files
# Sets generated code for all migrations
[*]
generated_code = true

它将禁用所有分析器,这使我的IDE在所有迁移中都更加快乐.

It will disable all analyzers, which makes my IDE much happier with all the migrations.

注意:需要Visual Studio 16.5

Note: requires Visual Studio 16.5

这篇关于如何处理庞大的efcore迁移设计器文件,这会减慢构建和IDE的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 00:34