efcore icon indicating copy to clipboard operation
efcore copied to clipboard

How is the file <project folder>\obj\<project>.csproj.EntityFrameworkCore.targets generated?

Open WillBaldwin opened this issue 5 years ago • 2 comments

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 avatar Dec 01 '21 16:12 WillBaldwin

@WillBaldwin Please post your full .csproj file so we can investigate.

ajcvickers avatar Dec 02 '21 17:12 ajcvickers

The issue turned out to be Windows Defender Ransomware Protection selectively blocking dotnet.exe file and folder actions. To solve the issue:

  1. Enable Controlled Folder Access
  2. Allow an app through Controlled folder access
  3. Add an allowed app: "C:\Program Files\dotnet\dotnet.exe"

WillBaldwin avatar Dec 03 '21 14:12 WillBaldwin