Corely.IAM.DataAccessMigrations.Cli
5.0.0
See the version list below for details.
dotnet tool install --global Corely.IAM.DataAccessMigrations.Cli --version 5.0.0
dotnet new tool-manifest
dotnet tool install --local Corely.IAM.DataAccessMigrations.Cli --version 5.0.0
#tool dotnet:?package=Corely.IAM.DataAccessMigrations.Cli&version=5.0.0
nuke :add-package Corely.IAM.DataAccessMigrations.Cli --version 5.0.0
Corely IAM Database Migration CLI
Creates and migrates the Corely IAM database schema. This is the supported way to stand up the IAM tables. The library itself never applies migrations at runtime.
The tool ships both provider migration sets, so nothing beyond it needs to be referenced.
| Provider | Value |
|---|---|
| SQL Server | MsSql |
| MySQL | MySql |
Install
dotnet tool install --global Corely.IAM.DataAccessMigrations.Cli
The command is corely-iam-db.
The tool's major version tracks the library's: CLI 3.x targets Corely.IAM 3.x. Minor and patch versions move independently, since most IAM releases add no migrations.
Configuration
Every db command takes the provider and connection string as options, falling back to environment
variables:
| Option | Environment variable |
|---|---|
-p, --provider |
CORELY_IAM_DB_PROVIDER |
-c, --connection-string |
CORELY_IAM_DB_CONNECTION |
The option wins when both are present. There is no settings file: an installed tool would have to keep one in its own install directory, shared by every repository and CI job on the machine.
# Per invocation
corely-iam-db db create -p MsSql -c "Server=(localdb)\MSSQLLocalDB;Database=CorelyIam;Trusted_Connection=True;"
# Or once per shell
export CORELY_IAM_DB_PROVIDER=MsSql
export CORELY_IAM_DB_CONNECTION="Server=(localdb)\MSSQLLocalDB;Database=CorelyIam;Trusted_Connection=True;"
corely-iam-db db create
$env:CORELY_IAM_DB_PROVIDER = "MsSql"
$env:CORELY_IAM_DB_CONNECTION = "Server=(localdb)\MSSQLLocalDB;Database=CorelyIam;Trusted_Connection=True;"
corely-iam-db db create
Commands
| Command | Description |
|---|---|
db create |
Create the database and apply all migrations |
db migrate [target] |
Apply pending migrations, or migrate to a specific target (0 reverts all) |
db status |
Show applied and pending migrations |
db list |
List all available migrations |
db script [from] [to] |
Generate a SQL script from migrations |
db drop [-f] |
Drop the database (-f skips confirmation) |
db test-connection |
Test the database connection |
platform bootstrap |
Create the platform account and its owner, once (below) |
provider list |
List available database providers |
db status and db list take -a, --show-all to include migrations belonging to other contexts
in the same database. db script takes -o, --output to write to a file and -i, --idempotent
for a script that is safe to run repeatedly.
Bootstrapping the platform account
platform bootstrap creates the optional platform account and a
dedicated owner user, once. Run it after db migrate. Besides the provider and connection string it
needs the application's system key, because IAM encrypts each user's keys with it.
| Option | Environment variable | Required |
|---|---|---|
-s, --secrets |
Yes: a file that does not exist yet | |
-e, --email |
Yes: the owner's email address | |
-k, --system-key |
CORELY_IAM_SYSTEM_KEY |
Yes |
--settings |
One of these two: the host's appsettings.json |
|
--use-defaults |
One of these two: the built in defaults | |
-u, --username |
No: defaults to platform-owner |
|
-a, --account-name |
No: defaults to Platform |
corely-iam-db platform bootstrap --email owner@example.com --secrets .\platform-owner.txt `
--settings ..\MyApp\appsettings.json
Once a platform account exists, the platform's security settings (password rules, lockout, token
lifetimes and the two factor settings) replace those sections of the host's configuration.
--settings starts them from the SecurityOptions and PasswordValidationOptions sections of that
file, and --use-defaults from the built in defaults. It reads only the file named, so name the one
holding the values the host really runs with. An out of range value fails the bootstrap before
anything is written. See where security settings come from.
The owner gets a generated password and two factor sign in enrolled. The username, password, authenticator secret and recovery codes go to the secrets file and nowhere else. A second run reports that the platform account exists and changes nothing. The application gives the platform owner its own resource types the next time it starts.
Every platform member, not only this owner, needs two factor sign in enabled to enter the platform account or any account through it.
Migrations history table
IAM records its migrations in __CorelyIamMigrationsHistory rather than the default
__EFMigrationsHistory, so it can share a database with your own contexts without their migration
records interleaving.
A database that was migrated before this default existed has its IAM history in
__EFMigrationsHistory. Either keep using it:
corely-iam-db db migrate --history-table __EFMigrationsHistory
or copy the records across once and drop the option:
-- SQL Server
SELECT * INTO __CorelyIamMigrationsHistory FROM __EFMigrationsHistory;
-- MySQL
CREATE TABLE __CorelyIamMigrationsHistory AS SELECT * FROM __EFMigrationsHistory;
That copies everything, which is what you want when IAM is the only context in the database. If it
shares the database, restrict the copy to the migration ids corely-iam-db db list reports.
Run db status afterwards: every IAM migration should read as applied. If they read as pending,
the copy did not land and migrating would try to recreate tables that already exist.
Examples
# First-time setup
corely-iam-db db create -p MsSql -c "<connection string>"
# Deployment script, reviewed before it runs anywhere
corely-iam-db db script -i -o deploy.sql -p MsSql
# CI or a test fixture with a container-assigned connection string
CORELY_IAM_DB_PROVIDER=MsSql CORELY_IAM_DB_CONNECTION="$CONN" corely-iam-db db create
db script needs a provider but never opens a connection, so it works offline.
Authoring migrations
Creating migrations is a development task that needs the repository, not this tool. Use the scripts at the repository root, which target both providers:
.\AddMigration.ps1 "MigrationName"
.\RemoveMigration.ps1
.\ListMigrations.ps1
Notes
- Every command exits with
0on success and1when it reports an error, so scripts can check it. db createis safe to run against an existing database. It applies whatever is pending.db migrate 0reverts all migrations but does not drop the database.db dropis destructive and cannot be undone.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.3.0 | 65 | 11/16/2026 |
| 7.2.0 | 114 | 11/9/2026 |
| 7.1.0 | 97 | 11/9/2026 |
| 7.0.0 | 101 | 11/8/2026 |
| 6.2.0 | 132 | 11/1/2026 |
| 6.1.0 | 117 | 10/27/2026 |
| 6.0.1 | 109 | 10/27/2026 |
| 6.0.0 | 103 | 10/27/2026 |
| 5.0.0 | 148 | 10/16/2026 |
| 4.0.1 | 123 | 10/13/2026 |
| 4.0.0 | 105 | 10/12/2026 |
| 3.1.1 | 109 | 10/11/2026 |
| 3.1.0 | 119 | 10/10/2026 |
| 3.1.0-preview.1 | 77 | 10/4/2026 |
| 3.0.0 | 123 | 10/2/2026 |
| 2.1.0 | 109 | 10/1/2026 |
| 2.0.2 | 123 | 9/25/2026 |
| 2.0.1 | 143 | 9/7/2026 |
| 2.0.0 | 125 | 9/4/2026 |
| 1.0.0 | 128 | 9/4/2026 |