6

Entity FrameworkとElastic Clientデータベースライブラリを使用して一部のモデルをSQL Azureに定期的に保存しようとする新しいサービスファブリックサービスを作成しました。 SQL Azure弾性スケールクライアントライブラリ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. 
+0

この問題の最小限の説明を共有できますか? –

+0

私も同様の問題があります。解決策を見つけましたか? –

+0

私はweb.configで接続文字列を設定するのを忘れてしまった。 –

答えて

2

私は、DBのコンテキストで私の.NETフレームワークのDLLにEnable-Migrationsコマンドの-StartUpProjectNameパラメータを指定することで、同じ例外の問題を解決してきました。問題は.IsWebProject()(私の場合はasp.core)の問題です。詳しくはEnable-Migrations Exception calling "SetData" with "2" argument(s)をご覧ください。

関連する問題