question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`dotnet ef migrations` Invalidates SLN Cache, Resulting a Full Recompile

See original GitHub issue

Ask 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:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davidrothcommented, Sep 7, 2021

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.

0reactions
bricelamcommented, Sep 16, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

PMC Tools: Build only the active project, not the whole ...
Unfortunately using the dotnet ef equivalent seems to invalidate all projects in my solution, seemingly replacing one problem with another.
Read more >
EF Core add-migration Build Failed
We've verified that the project builds, and the entire solution builds. We've done "dotnet restore" and rebuild all multiple times, in addition ...
Read more >
EF - Add Migration Error - Microsoft Q&A
Try to re-install the Microsoft.EntityFrameworkCore.Tools package and clear the NuGet Cache: uninstall Microsoft.EntityFrameworkCore.Tools ...
Read more >
Error with Scaffolding datamodel for Asp.Net
I added Asp.Net MVC, then simple Datamodel class library with EF Core and scaffolded Northwind DB. Then I clicked on Controller, add ->...
Read more >
Resetting Entity Framework Migrations to a clean Slate
I've had a number of problems with Entity Framework Migrations getting out ... code you can delete the file or the entire Migrations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found