You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行dotnet ef迁移时触发MSB1006错误的排查与解决

Fix: MSBUILD Error MSB1006 When Running EF Core Migrations

If you're hitting the MSBUILD : error MSB1006: Property is not valid error while trying to run Entity Framework Core migration commands, here's the breakdown of the issue and how to fix it.

The Problem Scenario

When executing commands like:

dotnet ef migrations add 

or

dotnet ef migrations script 

you'll get a confusing error message that looks like this:

MSBUILD : error MSB1006: Property is not valid. Switch: \tmpBCE7.tmp For switch syntax, type "MSBuild /help" Unable to retrieve project metadata. Ensure it's an MSBuild-based .NET Core project. If you're using custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option. 

At first glance, this makes it seem like there's an issue with your project configuration or MSBuild setup—but the actual root cause is much simpler.

The Solution

I stumbled on the fix while checking environment variables for an unrelated task: the problem was an extra semicolon at the end of the TMP user environment variable.

Here's how to resolve it:

  • Open your system's environment variables settings (on Windows, go to Control Panel > System > Advanced System Settings > Environment Variables)
  • Under the "User variables" section, locate the TMP variable
  • Edit its value to remove the trailing semicolon
  • Save the changes, then restart your terminal or IDE to apply the updated environment variable

Once you've done this, re-run your EF migration commands—they should execute without triggering the MSB1006 error.

内容的提问来源于stack exchange,提问作者BDarley

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 09:00:40