`dotnet ef migrations` Invalidates SLN Cache, Resulting a Full Recompile
See original GitHub issueAsk a question
This issue started with #25524 which led to #9716, which suggested using the corresponding dotnet ef
commands. I was happy with using this workaround and closed the issue.
Unfortunately, it appears the workaround also suffers from an issue, which is that it seems to invalidate the SLN/build cache when it runs.
The result of this is a full rebuild of the solution the next time this is attempted in Visual Studio. For larger solutions this takes time and feels disruptive. I made mention of this in https://github.com/dotnet/efcore/issues/9716#issuecomment-911914458 but did not hear anything back so ensuring this is captured here.
I did some searching in the issues as well and no results showed up. However, I have not had too much luck with it or GitHub search so this may be already captured. Please let me know if so and I will close the issue.
You know, standard procedure. 😆
Include your code
First, I run dotnet clean
and SHIFT-CTRL-B
on my SLN:
========== Build: 130 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
SHIFT-CTRL-B
again to be sure:
========== Build: 0 succeeded, 0 failed, 130 up-to-date, 0 skipped ==========
I then run the following commands:
dotnet ef database drop -f -v --project Starbeam.Model.Schema --startup-project Starbeam.Model.Schema
dotnet ef migrations remove -v --project Starbeam.Model.Schema --startup-project Starbeam.Model.Schema
dotnet ef migrations add Initial -v --project Starbeam.Model.Schema --startup-project Starbeam.Model.Schema
Finally, after that is complete, I run SHIFT-CTRL-B
once more in Visual Studio:
========== Build: 129 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
FWIW this is with 6.0.0-rc.2.21452.6
tools.
Include stack traces
NA
Include verbose output
NA
Include provider and version information
EF Core version: 6.0.0-rc.2.21452.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: net6.0
Operating system: Windows 10
IDE: Visual Studio 2022 Preview 3.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Is the project Starbeam.Model.Schema explicitly or implicitly referenced by the other 129 projects? If so, it makes sense, because with
migrations add
you are adding additional types to the project which requires recompilation of the downstream projects.Without debugging it, my initial thought is that we should probably remove this file before building again:
https://github.com/dotnet/efcore/blob/b634979c2f16fc2cb0489c5138067c03ef1f5216/src/dotnet-ef/Project.cs#L61-L71