在VS2017 Professional的程序包管理器控制台窗口中使用命令时
Scaffold-DbContext "server=server;uid=username;pwd=password;database=database" IBM.EntityFrameworkCore -force
具有以下依赖性:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IBM.EntityFrameworkCore" Version="1.3.0.100" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.4" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
我遇到以下异常:
System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpDbContextGenerator..ctor(Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingProviderCodeGenerator, Microsoft.EntityFrameworkCore.Design.IAnnotationCodeGenerator, Microsoft.EntityFrameworkCore.Scaffolding.Internal.ICSharpUtilities)'.
at IBM.EntityFrameworkCore.Scaffolding.Internal.Db2CSharpDbContextGenerator..ctor(IScaffoldingProviderCodeGenerator providerCodeGenerator, IAnnotationCodeGenerator annotationCodeGenerator, ICSharpUtilities cSharpUtilities)
应该注意的是,在同一解决方案中还有另一个项目也使用EntityFramework Core for SQL Server,该项目正在通过Scaffold-DbContext命令生成数据库上下文。