c# - 由于 Mac 上的 Windows,Enable-Migrations 无法工作

标签 c# entity-framework nuget-package migrate

我是 Mac 用户,但想通过 Visual Studio 使用 C# 进行开发。因此,我有一个Parallels帐户,它是一个在使用时将操作系统切换到Windows的程序。

首先,让我介绍一下我遇到的错误:(尝试从 NuGet 包管理器内的包管理器控制台执行此操作)

Cannot determine a valid start-up project. Using project 'CodeFirstNewDatabaseSample' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information.

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file://\Mac\Home\Desktop\Visual Studio 2015\Projects\CodeFirstNewDatabaseSample\packages\EntityFramework.6.1.3\tools\E ntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" At \Mac\Home\Desktop\Visual Studio 2015\Projects\CodeFirstNewDatabaseSample\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:62 + $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll)) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression. At \Mac\Home\Desktop\Visual Studio 2015\Projects\CodeFirstNewDatabaseSample\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:50 + $dispatcher = $utilityAssembly.CreateInstance <<<< ( + CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file://\Mac\Home\Desktop\Visual Studio 2015\Projects\CodeFirstNewDatabaseSample\packages\EntityFramework.6.1 .3\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" At \Mac\Home\Desktop\Visual Studio 2015\Projects\CodeFirstNewDatabaseSample\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:31 + $domain.CreateInstanceFrom <<<< ( + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

VS2015 目前已下载到我的系统上。我有一个模型类和一个本地数据库,但从现在开始我希望能够通过迁移更改数据库。然而,我在实现它时遇到了困难,我认为背后的原因是 Windows 在 Mac 上的位置为 this question建议。我这样想是因为当我想访问 Windows 系统上的 Visual Studio 项目时,我从 网络位置 下名为 Home on 'Mac'(Y:) 的目录进入em> (我遵循的确切路径是“Mac”上的计算机->主页(Y:)[在“网络位置”选项卡下]->文档->Visual Studio 2015)。同样,正如问题中的答案所暗示的那样,我将其剪切并粘贴到 Windows 系统的桌面上。但后来我意识到,我只能从计算机目录中的网络位置选项卡访问桌面。

我希望有人以前遇到过同样的问题并解决了,这样他就可以帮助我解决这个问题。

等待您的好答案,

谢谢

最佳答案

我有相同的配置(OSX + Parallels)并且遇到了与您相同的问题。当源代码位于 OSX 共享文件夹上时,EF 包管理器控制台会抛出该消息。正如您的链接所述,问题不在于 Mac+Parallels,而在于代码位于网络位置。

如果您将代码移至虚拟机的桌面,并且 Parallels 配置为在 Mac 和 Windows 之间共享桌面,则它可能仍然是网络位置。只需尝试一些纯 Windows 位置,如 C:\VsProjects

我最终将代码移至 Windows 位置,它对我来说效果更好,但如果您想将代码保留在网络文件夹中,只需使用 -StartupProjectName 并明确指定那里的可执行项目。

关于c# - 由于 Mac 上的 Windows,Enable-Migrations 无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35270025/

相关文章:

powershell - 在不使用 PowerShell 的情况下在 Nuget 包中嵌套文件

visual-studio - 无法加载文件或程序集 Visual Studio 2019(社区)

c# - Web服务代理类实现接口(interface)

C# Entity Framework 6 上下文对象数据库首先使用现有的 DbConnection

c# - XNA 截图显示了 pre-Bloom,而不是最终渲染

entity-framework - 应该在哪里应用 AsNoTracking?

entity-framework - 无法将表从服务器资源管理器拖到 .edmx 设计器 Pane

visual-studio - 从 VS2013 中删除 NuGet 包管理器

c# - 更改按钮背景

c# - 改进 Linq 查询