How is the file <project folder>\obj\<project>.csproj.EntityFrameworkCore.targets generated?
How is the file "[project folder]\obj\[project].csproj.EntityFrameworkCore.targets" generated?
My dbContext works fine and my CRUD operations all work as intended. In my project, the file is missing even after cleaning and re-compiling my project. How might I force the file to be regenerated?
Example CLI Errors
dotnet ef --version Entity Framework Core .NET Command-line Tools 6.0.0
dotnet ef migrations list System.IO.FileNotFoundException: Could not find file '\[solution]\[project]\obj\[project].csproj.EntityFrameworkCore.targets'.
dotnet ef migrations add init0 System.IO.FileNotFoundException: Could not find file '\[solution]\[project]\obj\[project].csproj.EntityFrameworkCore.targets'.
I have the following NuGet packages in my project
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore Version="6.0.0" Microsoft.AspNetCore.Identity.EntityFrameworkCore Version="6.0.0" Microsoft.AspNetCore.Identity.UI Version="6.0.0" Microsoft.EntityFrameworkCore Version="6.0.0" Microsoft.EntityFrameworkCore.SqlServer Version="6.0.0" Microsoft.EntityFrameworkCore.Tools Version="6.0.0" Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore Version="6.0.0" Microsoft.Extensions.Identity.Core Version="6.0.0"
@WillBaldwin Please post your full .csproj file so we can investigate.
The issue turned out to be Windows Defender Ransomware Protection selectively blocking dotnet.exe file and folder actions. To solve the issue:
- Enable Controlled Folder Access
- Allow an app through Controlled folder access
- Add an allowed app: "C:\Program Files\dotnet\dotnet.exe"