gpt4 book ai didi

macos - Visual Studio Mac Preview Entity Framework SQLite 添加迁移

转载 作者:行者123 更新时间:2023-12-04 17:07:42 26 4
gpt4 key购买 nike

我今天已经安装了 Visual Studio for Mac (OSX 10.12.1),并且我一直在深入研究。

我想尝试让 EntityFrameworkCore (1.1.0) 与 SQLite 一起运行。

因此,我创建了一个新的控制台应用程序 .NET Core,并且在添加所有必要的 nuget 包时遇到了一些麻烦。不知何故,Visual Studio 无法下载依赖项,所以我不得不手动下载每个依赖项。 (也许这解决了问题:.Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac 还没有对此进行测试。)

如本文 ( https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite ) 所述,我想添加迁移,但在 IDE 中找不到必要的命令行工具。
我在这里错过了什么吗?

然后我继续使用 .NET Core CLI 通过手动完成。安慰。 ( https://www.microsoft.com/net/core#macos )。但是当我执行 dotnet ef migrations add init 时出现以下错误。

No executable found matching command "dotnet-ef"



有没有人能够让它成功运行?

最佳答案

Visual Studio for Mac 2017 当前(2017 年 4 月)不支持添加对 Microsoft.EntityFrameworkCore.Tools.DotNet 的引用并返回错误:

Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 1.0.0' has a package type 'DotnetCliTool' that is not supported by project 'MacMvc'.

您可以手动编辑文件并将引用直接添加到 csproj 文件中,如 documented 。将此添加到您的 csproj 文件中:
  <ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>

然后运行 ​​ dotnet restore 安装包。之后,您将能够根据文档使用 dotnet ef migrations add NameOfMigrationdotnet ef database update 脚本。

注意:执行命令时必须在项目目录中。

另请参阅 VS 2017 for Mac 的建议反馈:
  • https://visualstudio.uservoice.com/forums/563332-visual-studio-for-mac/suggestions/17169425-add-sql-server-integration
  • https://visualstudio.uservoice.com/forums/563332-visual-studio-for-mac/suggestions/17138506-terminal-window
  • 关于macos - Visual Studio Mac Preview Entity Framework SQLite 添加迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40850156/

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