未找到方法:'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)'
Method not found: 'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)'
我正在使用 C#,我想 Add-Migration InitialVersion
但有一个问题:
Method not found: 'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)'
我使用的Nuget包:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.2.21154.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.2.21154.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
</ItemGroup>
</Project>
将 Microsoft.EntityFrameworkCore
和 Microsoft.EntityFrameworkCore.Tools
降级到最新的 5th 版本。您可以使用下一个命令通过 dotnet CLI 执行此操作:
dotnet add package Microsoft.EntityFrameworkCore --version 5.0.4
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 5.0.4
Indexer accepting string
was removed from IAnnotatable
in the 6th preview version.
另一种选择是将 dotnet-ef 更新为与您的项目中相同的版本
dotnet tool update --global dotnet-ef --version 6.0.0-preview.2.21154.2
我正在使用 C#,我想 Add-Migration InitialVersion
但有一个问题:
Method not found: 'System.Object Microsoft.EntityFrameworkCore.Infrastructure.IAnnotatable.get_Item(System.String)'
我使用的Nuget包:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.2.21154.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.2.21154.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0-alpha.2" />
</ItemGroup>
</Project>
将 Microsoft.EntityFrameworkCore
和 Microsoft.EntityFrameworkCore.Tools
降级到最新的 5th 版本。您可以使用下一个命令通过 dotnet CLI 执行此操作:
dotnet add package Microsoft.EntityFrameworkCore --version 5.0.4
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 5.0.4
Indexer accepting string
was removed from IAnnotatable
in the 6th preview version.
另一种选择是将 dotnet-ef 更新为与您的项目中相同的版本
dotnet tool update --global dotnet-ef --version 6.0.0-preview.2.21154.2