Albatross.EFCore.Admin
8.1.1
Prefix Reserved
dotnet add package Albatross.EFCore.Admin --version 8.1.1
NuGet\Install-Package Albatross.EFCore.Admin -Version 8.1.1
<PackageReference Include="Albatross.EFCore.Admin" Version="8.1.1" />
<PackageVersion Include="Albatross.EFCore.Admin" Version="8.1.1" />
<PackageReference Include="Albatross.EFCore.Admin" />
paket add Albatross.EFCore.Admin --version 8.1.1
#r "nuget: Albatross.EFCore.Admin, 8.1.1"
#addin nuget:?package=Albatross.EFCore.Admin&version=8.1.1
#tool nuget:?package=Albatross.EFCore.Admin&version=8.1.1
About
A library that can be used to create efcore admin commandline utility.
Quick Start
The library contains the following generic utilities:
- ExecuteMigrationScripts - A command that will execute sql scripts. It takes on a
dependency on interface IExecuteScriptFile. The interface should be registered with one of
the two implementations ExecuteScriptFile
or ExecuteSqlServerScriptFile.
--directory
is a required option to specify the input script directory. The utility will only execute scripts within a subfolder of the directory whose name matches the version of the entry assembly. For example, if the input directory isc:\deployment
and the entry assembly version is2.0.0
, the target folder would bec:\deployment\2.0.0
. The prerelease part of the version will not be considered as part of the folder name. Version2.0.0-prerelease
and2.0.0
will have the same target folder of2.0.0
.- If the
--pre-migration
flag is set, the command should be executed prior the actual migration. The utility however will skip execution if the target database has no pending migrations.
- EFMigrate - A command that will execute the efcore migration
- GenerateSqlScript - A command that will generate the sql script for a specific db context.
Putting it all together
Use the following sample projects for reference
Notice that the Sample.Admin
project leverages the utilities of the Albatross.EFCore.Admin
project by
creating verbs that reference the admin project. The Sample.Admin
only needs to create its
own migration db context such as SampleSqlMigration
and SamplePostgresMigration.
Since most projects only target either sql server or postgres, the code in Sample.Models
and Sample.SqlServer
or
Sample.Postgres
could be combined into a single project. But an admin project such as Sample.Admin
should always be
used to seperate the admin utility from the actual program itself. Sample.Admin
contains its own dbcontext
class SamplePostgresMigration that derives from the actual db context
class SampleDbSession because migration dbcontext has different requirements.
- At the root of the admin project, generate the efcore migration using the dotnet efcore utility
dotnet ef migrations add SampleSqlServerMigration_$name --context SampleSqlServerMigration --output-dir (Get-Path Migrations, SqlServer)
- Run the migration by calling the ef-migrate command of the
Sample.Admin
project
Sample.Admin.exe sql ef-migrate --verbose Information
- Run the script generation command to see and verify the actual table setup.
Sample.Admin.exe sql create-sql-script;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Albatross.CommandLine (>= 7.8.5)
- Albatross.EFCore.PostgreSQL (>= 8.1.1)
- Albatross.EFCore.SqlServer (>= 8.1.1)
- Albatross.SemVer (>= 2.0.0)
- Microsoft.EntityFrameworkCore (>= 8.0.14)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.14)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.