私は、データサービスとしてASP.NET Web APIを使用し、クライアントとしてXamarinポータブルアプリケーションを使用するプロジェクトを開発しています。VS 2015 ASP.NET Web API(EF6)とXamarin Enable-Migrationsが失敗する
私は、Webアプリでの移行を可能にしようとしているが、私は次のエラーを取得する:
Enable-Migrations -enableautomaticmigrations -ContextTypeName MyProject.Models.ApplicationDbContext -ProjectName MyProject -StartupProjectName MyProject.App -Verbose
Using StartUp project 'MyProject.App'.
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:\Users\weitz\.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:718 char:5
+ $domain.SetData('project', $project)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
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:\Users\weitz\.nuget\packages\EntityFramework\6.1.3\tools\EntityFramework.psm1:719 char:5
+ $domain.SetData('contextProject', $contextProject)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SerializationException
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
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.
**PM>**
あなたが見ることができるように、私は明示的に起動するプロジェクトを指定しようとしましたが、見ていませんenable-migrationsコマンドのようにそれはとても幸せです。
これは私が作成したばかりのプロジェクトで、完全な.NET(私はまだEFコアでサポートされていないTPT/TPHモデルにバインドされています)ですので、EFバージョンは.NET 4.6.1を対象とした6.1.3です。
私はVS Community 2015 Update 3バージョン14.0.25431.01です。
更新
は再現することはできませんが、ダミーの起動プロジェクトを追加する場合でも、問題が発生します。
クロス投稿の問題here、投票して実験を共有してください。
スタートアッププロジェクトに、データベースへの接続に使用するapp.configまたはweb.configが含まれていますか。 dbcontextを含むプロジェクトをスタートアッププロジェクトとして使用することもできます。 – jomsk1e
appsettings.jsonを使用して接続文字列を保存します。しかし、私はapp.configに接続文字列を追加しようとしたが、それは役に立たなかった。 – Shimmy