[英]Enable-Migrations is obsolete. Use Add-Migration to start using Migrations
好的,但是我們在 Configuration 過時之前使用的以下設置呢?
public Configuration()
{
//AutomaticMigrationsEnabled = true; //it is Ok for now as default value is true
//what about the following settings???
AutomaticMigrationDataLossAllowed = true; //Attention when using this!!!
MigrationsDirectory = @"Migrations";
ContextKey = "Demo.Domain.DemoDbContext";
}
我在哪里可以設置這些設置?
安裝EntityFrameworkCore.Tools
包,以便在包管理器控制台中使用 Add-Migration 和 Update-Database 等命令。 您不需要調用 Enable-Migrations,作為旁注, AutomaticMigrationsEnabled
已過時。
在 PM 控制台中,您始終可以使用以下命令運行--help
命令: dotnet ef migrations add --help
。
然后您將能夠看到所需的所有配置:
Usage: dotnet ef migrations add [arguments] [options]
Arguments:
<NAME> The name of the migration.
Options:
-o|--output-dir <PATH> The directory (and sub-namespace) to use. Paths are relative to the project directory. Defaults to "Migrations".
--json Show JSON output.
-c|--context <DBCONTEXT> The DbContext to use.
-p|--project <PROJECT> The project to use.
-s|--startup-project <PROJECT> The startup project to use.
--framework <FRAMEWORK> The target framework.
--configuration <CONFIGURATION> The configuration to use.
--runtime <RUNTIME_IDENTIFIER> The runtime to use.
--msbuildprojectextensionspath <PATH> The MSBuild project extensions path. Defaults to "obj".
--no-build Don't build the project. Only use this when the build is up-to-date.
-h|--help Show help information
-v|--verbose Show verbose output.
--no-color Don't colorize output.
--prefix-output Prefix output with level.
例如,如果要將目錄設置為 Migrations(這是默認設置):
dotnet ef migrations add MyMigration --output-dir Migrations
或者在指定 DbContext 時添加遷移:
dotnet ef migrations add MyMigration --context MyDbContext
Enable-Migrations 適用於舊版本。 添加遷移的新版本支持
首先輸入 add-migration "setupName" 。
設置名稱是任何可識別的名稱,例如:添加遷移“initialSetup”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.