无法检索元数据项目。确保它的SDK风格项目

发布于 2025-01-29 05:20:45 字数 1151 浏览 4 评论 0原文

我有一个由4个项目组成的解决方案,如屏幕截图 ”我的解决方案布局的屏幕快照

dbContext在newkyc.data项目中。启动项目是newkyc

启动的配置方法。CS包含以下块

services.AddDbContext<AppDbContext>(
           dbContextOptions => dbContextOptions
              .UseMySql(Configuration["ConnectionStrings:MySQLConnection"], 
              new MySqlServerVersion(new Version(mysql_version[0], mysql_version[1], mysql_version[2])), b=>b.MigrationsAssembly("NewKyc")

以添加迁移,我编写以下内容

dotnet ef migrations add EntityRelationshipsReview --startup-project "../NewKyc.csproj" --context AppDbContext --verbose

,然后收到以下消息

msbuild:错误msb1009:项目文件不存在。 switch:/users/mac/documents/projects/folder/subfolder/subsubfolder/newkyc.csproj

and shise

无法检索项目元数据。确保它是一个SDK风格的项目。如果您使用的是自定义的baseinteriateOutputpath或msbuildProjectExtensionsPath值,请使用-MSBuildProjectExtensenspath选项。

我在哪里弄错了?

它是一个.NET Core 3.1项目升级到.NET 6

I have a solution that is made up of 4 projects as shown in the screenshot Screenshot of my solution layout

The DbContext is inside NewKyc.Data project. The startup project is NewKyc

The ConfigureServices method of the Startup.cs contains the following block

services.AddDbContext<AppDbContext>(
           dbContextOptions => dbContextOptions
              .UseMySql(Configuration["ConnectionStrings:MySQLConnection"], 
              new MySqlServerVersion(new Version(mysql_version[0], mysql_version[1], mysql_version[2])), b=>b.MigrationsAssembly("NewKyc")

To add migrations, I write the following

dotnet ef migrations add EntityRelationshipsReview --startup-project "../NewKyc.csproj" --context AppDbContext --verbose

and I get the following messages

MSBUILD : error MSB1009: Project file does not exist.
Switch: /Users/mac/Documents/Projects/folder/subfolder/subsubfolder/NewKyc.csproj

And this

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.

Where am I getting it wrong?

It is a .NET Core 3.1 project upgraded to .NET 6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻拂→两袖风尘 2025-02-05 05:20:45

由于您已从Net Core 3.1升级到6.0,因此您的dotnet-ef Cli工具可能已过时,因此您可以在全球上进行更新,根据 docs ,使用以下命令:

dotnet工具更新-g dotnet-ef

或本地:

dotnet工具更新-Local dotnet-local dotnet -ef

Since you've upgraded from Net Core 3.1 to 6.0 it's possible your dotnet-ef CLI tool is out of date, you can update it globally, according to the docs, using the following command:

dotnet tool update -g dotnet-ef

Or locally:

dotnet tool update --local dotnet-ef

黎歌 2025-02-05 05:20:45

确保您包含到下面的文件夹的完整路径:

dotnet-ef migrations add Testing -s C:\\NewKYCSolution\\NewKYC -c ApplicationDbContext -p C:\\NewKYCSolution\\NewKYC.Data --no-build

尝试。

Make sure you include the full paths to the folders as below:

dotnet-ef migrations add Testing -s C:\\NewKYCSolution\\NewKYC -c ApplicationDbContext -p C:\\NewKYCSolution\\NewKYC.Data --no-build

Try that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文