私はすべての依存関係を1.1で正しく実行していると思いますが、ここで手順を実行しようとするとhttps://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db私はAdd-Migrationコマンドを実行中にエラーが発生します。起動クラス「スタートアップ」に関するメソッド「ConfigureServices」の呼び出し中にEFコア1.1からWebApiコア - 追加移行が失敗する
PM>アドオンの移行初期状態
エラーが発生しました。私project.jsonの
Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Error: This method could not find a user secret ID because the application’s entry assembly is not set. Try using the “.AddUserSecrets(Assembly assembly)” method instead. No parameterless constructor was found on ‘ApplicationDbContext’. Either add a parameterless constructor to ‘ApplicationDbContext’ or add an implementation of ‘IDbContextFactory’ in the same assembly as ‘ApplicationDbContext’.
関連セクション: ...
“Microsoft.EntityFrameworkCore”: “1.1.0”,
“Microsoft.EntityFrameworkCore.SqlServer”: “1.1.0”,
“Microsoft.EntityFrameworkCore.Design”: {
“type “: “build”,
“version”: “1.1.0”
},
“Microsoft.EntityFrameworkCore.Tools”: “1.1.0-preview4-final”
},
“tools”: {
“Microsoft.EntityFrameworkCore.Tools.DotNet”: “1.1.0-preview4-final”
},
私ApplicationDbContextはコンストラクタ持っている:
public ApplicationDbContext(DbContextOptions options) : base(options)
{ }
を、私のStartup.csを持っています:
services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString(“DefaultConnection”)));
ほかに何がありますか?あなたの問題はEFコアに関連していない
ありがとうハッサン。はい、上記のソリューションはVS2015用でした。私は最近VS2017に私のプロジェクトをアップグレードしてproject.jsonの代わりにCSPROJに入れているようになったので、あなたはもはやその属性を必要としません。 –