私は新しいasp.netコアを使用していますし、私のクラスとdbコンテキストをsep dllに持っています。asp.netコアの問題最初のデータベースの移行を追加する
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddDbContext<solitudeDContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")
,b=>b.MigrationsAssembly("solitudedcore")));
}
しかし、私はまだ私は、次のコマンドを実行したときに
DOTNETのEFの移行は、「solitudeeccore」あなたの移行と一致していないアセンブリ "firstdb
あなたのターゲットプロジェクトを追加し、次のエラーを取得しています孤独なコア '。ターゲットプロジェクトを変更するか、移行アセンブリを変更します。 DbContextOptionsBuilderを使用して移行アセンブリを変更します。例えば。 options.UseSqlServer(接続、b => b.MigrationsAssembly( "solitudeeccore"))。既定では、移行アセンブリはDbContextを含むアセンブリです。 Package Managerコンソールの[Default project]ドロップダウンリストを使用するか、またはmigrationsプロジェクトが格納されているディレクトリから "dotnet ef"を実行して、対象プロジェクトをmigrationsプロジェクトに変更します。
EFにここに指示されたように、私はプロジェクトにドロップダウンを変更し、B => b.MigrationsAssembly(「solitudedcore」)を追加したがgithubのhttps://github.com/aspnet/EntityFramework/issues/7869
をコア私はまた、私のプロジェクトは、あなたの参考のために含ま含ま。
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
そして、私のAppSettingsファイル
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": "Data Source=DESKTOP-JHIMUM4\\SQLEXPRESS2014;Initial Catalog=solitudeec;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
任意のアイデアや解決策を以下のように認識されるであろう。
してくださいここに私のプロジェクトのレイアウトを見つける
編集1
以下の人は、それはDLLの綴りであるだけでなく、あなたがホストするプロジェクトを対象とする必要が確かに正しかったですあなたのdllは実際のdll自体ではありません。 CMDプロンプトの呼び出しで
DOTNETのEFの移行を移行を作成するには
はfirstdb
を追加し、単に
DOTNET EFデータベース更新-eを呼び出して変更を押し出します生産
ので、私はそれが正しいので、コンテキストをinclduesアセンブリがsolitudedccoreある – david