English 中文(简体)
无法检索项目元数据。 • 确保它有一个基于MSBuild的平台。 NET Core Project. (特派团)
原标题:Unable to retrieve project metadata. Ensure it s an MSBuild-based .NET Core project. (Migrations)
问题回答

这是两年的,但我的情况是一样的,因此仍然具有相关性。 这是谷歌对这一错误的第一个结果。

因此,在你的屏幕上,我可以看到,你没有参加标准的视窗演播室,因此,我假定你没有在视窗上(在如何书写档案路上出现差异)。 我也看到你使用<代码>。

解决办法:将所有<代码>改为/,在您的案例中,我猜测:

dotnet ef migrations add ExampleMigration -s ../TooSeeWeb

对我来说,它正在视窗上工作,但因这一错误而未能在MacOS(OS X)上工作:

Unable to retrieve project metadata. Ensure it s an SDK-style project. If you re using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

此外,它还提供信息(这更能说明:

MSBUILD: 错误MSB1009: 项目档案不存在。

www.un.org/Depts/DGACM/index_spanish.htm 在此,我更复杂的发言,涉及前方的争lash:。

dotnet ef --startup-project ./MainProject.csproj migrations add MyMigration --context MyDbContextPostgreSQL --output-dir Migrations --project ../MyDatabasePostgreSQL/MyDatabasePostgreSQL.csproj

你必须提到你的网络项目。

 dotnet ef --startup-project ../TooSeeWeb migrations add MigrationName -c NameOfYourDBContext

https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/projects”rel=“noreferer”

我有同样的错误。 我通过将“核心”计划列入其中来解决:

Microsoft.EntityFrameworkCore.Tools

仅增加您启动项目和数据库项目的道路,如:

dotnet ef database update --verbose --project "src/Services/Discount/Discount.Infrastructure.Rdms" --startup-project "src/Services/Discount/Discount.Web"

这条道路应当与您目前对目的地名录的目录相对,例如,如果我把目前的目录改为/弧,道路将改为<代码>。 服务/差异/差异

我的问题是,该项目正处在解决方案的夹头上,因此,我必须具体指明项目道路——如:

dotnet ef migrations add InitialCreate --project SolutionName/ProjectName.csproj

我的错误类似,但不同。 事实上,与@CodingYourLife提到同样的错误(如果错误的措辞随着时间的推移而改变,或者实际上是一种不同的错误),那么不管怎么说。 这是错误:

Unable to retrieve project metadata. Ensure it s an SDK-style project. If you re using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.

It turned out that I needed to run the dotnet ef dbcontext scaffold <list_of_options> command from the parent folder (the one with the solution file in it - not from the PROJECT folder). I used cd .. (to move up one folder) and re-ran the command, and it created my database-context and EF classes for the tables specified.

我不知道这个问题如何出现,但是由于大多数发展者来自使用这些指挥系统:

dotnet ef migrations add "MigrationName" -s ../ProjectName
dotnet ef migrations remove -s ../ProjectName
dotnet ef database update -s ../ProjectName

我把他们替换为:

dotnet ef --startup-project ../ProjectName migrations add MigrationName -c DbContextName 
dotnet ef --startup-project ../ProjectName database update -c FoodTownDbContext

我认为,这同样适用,但经过测试:

dotnet ef --startup-project ../ProjectName migrations remove
-c DbContextName

我正在使用实体框架核心网指挥线工具6.0.10,以下工具为我工作。

  1. Make sure you install the EF tooling globally
    dotnet tool install dotnet-ef --global
    
  2. Make sure you update it to the latest
    dotnet tool update dotnet-ef --global
    
  3. Open a Powershell off your start up project. In your case, it would be TooSeeWeb? Your Powershell should default the root to something like
    PS C:your-usersource
    eposTooSeeWebsrcTooSeeWeb>
    
  4. Run the following command to add a migration
    dotnet ef migrations add ExampleMigration
      -c YourDbContext
      -p ../TooSeeWeb.Infrastructure
      -o Data/Migrations
    

应当确定你们想要移民的项目。

<代码>-o是你希望将文件输入的名录,与你刚用<代码>-p制作的项目目录相对照。

您也可以使用<代码>-s来制定启动项目,在其中你有关系。 但是,既然我宣布权力开始,我就不必说明这一点,因为它违反了目前的工作名录。


您可以做以下工作:dotnet ef migrations Add -h,以便看到整个任择论点清单和这些论点。

In my case it was caused by EF versions that I had installed. I had Entity Framework Core .NET Command-line Tools 7.0.1 installed and the project I was trying to add the migration to, was using EF 6.

Solution was to run EntityFramework6Add-Migration instead of Add-Migration

I had a similar experience with dotnetcore 3.1, and this worked for me.

Here s the project structure of my simple app:

  • ProjectWallet (API)
  • ProjectWallet.Data (DbContext, Models, etc)
  • ProjectWallet.Tests

I have Microsoft.EntityFrameworkCore installed on ProjectWallet.Data.

a. 向贵方目录在地契上居住的项目发放;

  • cd ProjectWallet.Data

随后运行;

  • dotnet ef migrations add Initial --startup-project "C:UsersPATH_TO_THE_STARTUP_PROJECT_PROJECTWALLET"

我添加了“太平洋建筑工程公司”的两句。

I hope this works for someone.

first of all, your need to see the exact context name. This is needed for

dotnet ef migrations Plus -c <your context name>

您通过利用这一指令,在您的项目中看到你的情况:

dotnet ef dbcontext list

你们会看到以下一点:

AspNetCore.Jwt.Sample.Config.MyIntIdentityContext AspNetCore.Jwt.Sample.Config.MyIdentityContext

见......情况不止一个。 选择

<代码>dotnet efmigration> - c AspNetCore.Jwt.Sample.Config.MyIntIdentityContext

如上文所述使用。

and! 它现在运作良好。

possible reasons:

为此:

dotnet ef migrations add <paramname> --startup-project ../<Web/Web.csproj> --project ../<Infrastructure/Infrastructure.csproj>

dotnet ef migrations remove --startup-project ../<Web/Web.csproj> --project ../<Infrastructure/Infrastructure.csproj>




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...