[英]Ef Core: How to put migrations for sveral different dbContexts to one assembly?
在我的應用程序中,我有兩個不同的 dbContexts(在兩個不同的程序集中),例如 DeliveriesDbContext 和 AuthenticationDbContext 但想將遷移放到一個命令行工具中。
所以我創建了命令行應用程序並嘗試為這兩個上下文生成遷移。
我可以指定遷移自定義文件夾名稱:
Add-Migration Intitial -OutputDir "DeliveriesDbContextMigrations"
但是如何指定將哪個上下文放入哪個文件夾?
Add-Migration
有一個名為-Context
的參數,它基本上用於具有多個提供程序的遷移,但在您提到的情況下它可以工作。
Add-Migration InitialCreate -Context MyDbContextOne -OutputDir Migrations\SqlServerMigrationsOne
Add-Migration InitialCreate -Context MyDbContextTwo -OutputDir Migrations\SqlServerMigrationsTwo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.