我剛創建了一個新的服務結構服務,它將定期嘗試使用Entity Framework和Elastic Client Database庫將某些模型保存到SQL Azure。我試圖儘可能地對SQL Azure Elastic Scale Client Library EF示例(Elastic DB Tools EF Sample)進行建模。我處於需要啓用遷移的地步,但是當我運行Enable-Migrations時,我收到以下錯誤消息。我使用的是ContextTypeName參數,因爲它聽起來像是最終需要針對具有不同模型的相同數據庫的不同服務結構服務所需的。有什麼建議麼?Enable-Migrations「未將對象引用設置爲對象的實例」
PM> Enable-Migrations -ContextTypeName "ServiceHealth.DbService"
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.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is
not marked as serializable."
At C:\eNowCloud\eNow.MicroServices\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.
你能夠分享這個問題的最小代價? –
我有類似的問題,你有沒有找到解決方案? –
原來我忘了在我的web.config中設置連接字符串。 –