About --idempotent Flag in dotnet ef migrations script
Entity Framework is commonly used in .NET applications. The feature I like most is to generate database migration scripts automatically. This is commonly used in DevOps projects to generate delta SQL scripts to apply to production databases automatically.
About dotnet ef migrations script
The usage of the command:
Usage: dotnet ef migrations script [arguments] [options]
Arguments:
<FROM> The starting migration. Defaults to '0' (the initial database).
<TO> The target migration. Defaults to the last migration.
Options:
-o|--output <FILE> The file to write the result to.
-i|--idempotent Generate a script that can be used on a database at any migration.
--no-transactions Don't generate SQL transaction statements.
-c|--context <DBCONTEXT> The DbContext to use.
-p|--project <PROJECT> The project to use. Defaults to the current working directory.
-s|--startup-project <PROJECT> The startup project to use. Defaults to the current working directory.
--framework <FRAMEWORK> The target framework. Defaults to the first one in the project.
--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. Intended to be used 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.
About --idempotent flag
As specified by the usage, this is used to generate a script that can be used on a database at any migration.
When this flag is set, the EF tool will generate scripts to check if any migration script is already applied to database; if yes, it will skip running that script.
Example
dotnet ef migrations script --idempotent
For more information, refer to official documentation: Applying Migrations.
copyright
This page is subject to Site terms.
comment Comments
No comments yet.