gpt4 book ai didi

asp.net-core - 无法加载类型 'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute'

转载 作者:行者123 更新时间:2023-12-03 16:41:06 27 4
gpt4 key购买 nike

我使用 Visual Studio for Mac,创建了一个 .net core web api 项目。
csproj 文件是这样的:

<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.9-dmr" />
<PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.9-dmr" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>

</Project>

当我使用以下命令从 MySQL 执行“dotnet ef dbcontext scaffold”到脚手架时:
dotnet ef dbcontext scaffold "server=[server];port=3306;user=[user];password=[password];database=[dbname]" MySql.Data.EntityFrameworkCore -o Models -c [contextname] -f -v

该命令返回如下错误:
Could not load type 'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute' from assembly 'Microsoft.EntityFrameworkCore, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

我检查了 Microsoft.EntityFrameworkCore 包。确实,该包中没有基础结构命名空间。但是在网上搜索,我发现其他人可以通过这样的设置成功搭建脚手架。
我做错了什么吗?
如何正确搭建脚手架?

谢谢你们。

最佳答案

你应该添加 Microsoft.EntityFrameworkCore.SqlServer来自 NuGet 包的包,这对我有用。希望,这也适用于您。

关于asp.net-core - 无法加载类型 'Microsoft.EntityFrameworkCore.Infrastructure.DesignTimeProviderServicesAttribute',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48321565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com