entity-framework - Service Fabric 和 Entity Framework 迁移

标签 entity-framework azure-service-fabric

我将 Service Fabric 与 Entity Framework 6.1.3 结合使用。当我尝试使用“Enable-Migrations”启用迁移时出现错误:

Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 
'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=14.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable."
At C:\repos\Gsa.Pops.Bookings\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:720 char:5
+     $domain.SetData('startUpProject', $startUpProject)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SerializationException

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetProjectTypes(Project project, Int32 shellVersion)
   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.IsWebProject(Project project)
   at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName, Boolean useContextWorkingDirectory)
   at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
   at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object reference not set to an instance of an object.

我想 EF 找不到连接字符串,因为起始项目是一个 Service Fabric 应用程序(所以没有 web.config,而是一个 ApplicationManifest.xml 和多个环境配置)

有什么线索吗? 谢谢, 阿尔贝托

最佳答案

您可以将连接字符串存储在 Azure 的 KeyVault 中,然后从那里提取您的基础设施项目。

关于entity-framework - Service Fabric 和 Entity Framework 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40419652/

相关文章:

entity-framework - Entity Framework (ASP.NET): How do you update the column mapping after adding a column to the framework?

c# - 使用 EF 查询映射 sql 查询不起作用

azure - 在 OnOpenAsync 方法中调用 GetOrAddAsync

c# - 在 Entity Framework 中使用带参数的存储过程

c# - 表不存在就创建?

c# - 分离时删除 Entity Framework Core 中的一比零或一相关数据 (sqlite)

azure-service-fabric - Service Fabric 应用程序之间的通信

c# - 为什么会不断调用 ICommunicationListener.Abort()?

microservices - 单个服务中的多个 FabricTransportServiceRemotingListeners

security - 保护 Service Fabric 集群但公开 API