如何解决如何使用 IDesignTimeDbContextFactory?
我正在尝试使用 dotnet cli ef 工具在具有两个 netstandard2.0 项目的存储库上进行迁移。 一个用于域,另一个用于基础设施,来自 eshop-on-container 的存储库的 Ordering Service,
我看到基础设施项目已经在 OrderingContext.cs 中实现了 IDesignTimeDbContextFactory
,
如果我错了,请纠正我,但据我所知,这意味着即使没有将启动项目传递给 dotnet cli ef 工具,我也可以在基础设施项目上进行迁移。
但是,当我这样做时,我收到以下错误
vscode ➜ /workspace/src/Ordering.Infrastructure (main) $ dotnet dotnet-ef migrations add init
Build started...
Build succeeded.
Startup project 'Ordering.Infrastructure.csproj' targets framework '.NETStandard'. There is no runtime associated with this framework,and projects targeting it cannot be executed directly. To use the Entity Framework Core .NET Command-line Tools with this project,add an executable project targeting .NET Core or .NET Framework that references this project,and set it as the startup project using --startup-project; or,update this project to cross-target .NET Core or .NET Framework. For more information on using the Entity Framework Tools with .NET Standard projects,see https://go.microsoft.com/fwlink/?linkid=2034781
这是基础设施项目的.csproj
文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ordering.Domain\Ordering.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<packagereference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</packagereference>
<packagereference Include="Microsoft.EntityFrameworkCore.sqlServer" Version="3.1.0" />
<packagereference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<packagereference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
我在这里遗漏了什么?为什么即使实现了 IDesignTimeDbContextFactory
我也无法进行迁移?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。