问题描述
我已经在网上进行了大量研究,但是没有找到合适的解决方案.我试图通过将数据库优先的脚手架方法映射到表模型来将Entity Framework Core与MySQL一起使用,而在应用命令时始终会收到此错误
I've been researching a lot online but did not find a proper solution. I was trying to use Entity Framework Core with MySQL by using database-first scaffold method to mapping table model while always received this error when applied the command
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.
这是我用来搭建数据库模型的命令:
This is the command I am using to scaffold the database model:
Scaffold-DbContext "server=localhost;port=3306;user=root;password=1234;database=world" "Pomelo.EntityFrameworkCore.MySql" -OutputDir .\Models -f
这是我的.Net Core项目设置:
And this is my .Net Core project setting:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
</ItemGroup>
推荐答案
我在尝试使用dotnet ef migrations add NewMigration
在命令行上添加新迁移时遇到此错误.
I got this error trying to add a new migration on the command line with dotnet ef migrations add NewMigration
.
对我来说,解决方案的确是添加--msbuildprojectextentionspath obj/local
.
The solution for me was indeed to append --msbuildprojectextentionspath obj/local
.
这篇关于无法检索项目元数据.确保这是一个基于MSBuild的.NET Core项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!