Albatross.EFCore.Admin 8.1.1

Prefix Reserved
This package has a SemVer 2.0.0 package version: 8.1.1+43997c9.
dotnet add package Albatross.EFCore.Admin --version 8.1.1
                    
NuGet\Install-Package Albatross.EFCore.Admin -Version 8.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Albatross.EFCore.Admin" Version="8.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Albatross.EFCore.Admin" Version="8.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.EFCore.Admin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Albatross.EFCore.Admin --version 8.1.1
                    
#r "nuget: Albatross.EFCore.Admin, 8.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Albatross.EFCore.Admin&version=8.1.1
                    
Install Albatross.EFCore.Admin as a Cake Addin
#tool nuget:?package=Albatross.EFCore.Admin&version=8.1.1
                    
Install Albatross.EFCore.Admin as a Cake Tool

About

A library that can be used to create efcore admin commandline utility.

Quick Start

The library contains the following generic utilities:

  1. 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 is c:\deployment and the entry assembly version is 2.0.0, the target folder would be c:\deployment\2.0.0. The prerelease part of the version will not be considered as part of the folder name. Version 2.0.0-prerelease and 2.0.0 will have the same target folder of 2.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.
  2. EFMigrate - A command that will execute the efcore migration
  3. 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.

  1. 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)
  1. Run the migration by calling the ef-migrate command of the Sample.Admin project
Sample.Admin.exe sql ef-migrate --verbose Information
  1. Run the script generation command to see and verify the actual table setup.
Sample.Admin.exe sql create-sql-script;
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.1.1 45 22 days ago
8.1.0 41 a month ago