我正在使用實體框架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無法找到連接字符串,因爲出發項目是一個服務光纖應用(所以沒有web.config文件,但在ApplicationManifest.xml和多個環境配置)
任何線索? 謝謝, Alberto
我不知道,如果不它會工作,但嘗試將遷移項目設置爲啓動項目。 – netchkin
最後我做了netchkin建議。我的「infrastucture」項目(帶有dbcontext和migrations的項目)是啓動項目。唯一的反退是我必須在該項目的app.config中手動複製連接字符串(連接字符串根據我正在處理的環境而不同) – Alberto