【发布时间】:2017-01-17 15:04:35
【问题描述】:
我将 Service Fabric 与 Entity Framework 6.1.3 一起使用。当我尝试使用“启用迁移”启用迁移时,出现错误:
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 和多个环境配置)
有什么线索吗? 谢谢, 阿尔贝托
【问题讨论】:
-
不知道能不能用,不过试试把有migrations的项目设置为启动项目吧。
-
最后我按照 netchkin 的建议做了。我的“基础设施”项目(带有 dbcontext 和迁移的项目)是启动项目。唯一的缺点是我必须在这个项目的app.config中手动复制连接字符串(连接字符串因我工作的环境而异)
标签: entity-framework azure-service-fabric