Albatross.EFCore.CodeGen 8.1.1

Prefix Reserved
This package has a SemVer 2.0.0 package version: 8.1.1+43997c9.
dotnet add package Albatross.EFCore.CodeGen --version 8.1.1
                    
NuGet\Install-Package Albatross.EFCore.CodeGen -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.CodeGen" Version="8.1.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Albatross.EFCore.CodeGen" Version="8.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.EFCore.CodeGen">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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.CodeGen --version 8.1.1
                    
#r "nuget: Albatross.EFCore.CodeGen, 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.CodeGen&version=8.1.1
                    
Install Albatross.EFCore.CodeGen as a Cake Addin
#tool nuget:?package=Albatross.EFCore.CodeGen&version=8.1.1
                    
Install Albatross.EFCore.CodeGen as a Cake Tool

About

A companion code generator used by the Albatross.EFCore library.

Features

Instead of using reflection at runtime, this library will generate entity model builder at compile time using roslyn.

Quick Start

  • Create an entity
    public class Address {
      public int Id { get; set; }
      public string? City { get; set; }
    }
    
  • Crate the entity mapping class for the entity
    public class AddressEntityMap : EntityMap<Address> {
      public override void Map(EntityTypeBuilder<Address> builder) {
          builder.HasKey(x => x.Id);
      }
    }
    
  • The code generator will pick up on the AddressEntityMap class and generate the following code
    public static ModelBuilder BuildEntityModels(this ModelBuilder modelBuilder)
    {
      new Sample.Models.AddressEntityMap().Build(modelBuilder);
      return modelBuilder;
    }
    
  • To consume the generated code, use it directly in your custom DbContext class
    public class SampleDbSession : DbSession {
      protected override void OnModelCreating(ModelBuilder modelBuilder) {
        modelBuilder.HasDefaultSchema(My.Schema.Sample);
        modelBuilder.BuildEntityModels();
      }
    }
    
  • To turn on the debugging model and see the generated code in visual studio, add the following config change to the project file.
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <EmitAlbatrossCodeGenDebugFile>true</EmitAlbatrossCodeGenDebugFile>
    </PropertyGroup>
    <ItemGroup>
        <CompilerVisibleProperty Include="EmitAlbatrossCodeGenDebugFile" />
    </ItemGroup>
</Project>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Albatross.EFCore.CodeGen:

Package Downloads
Albatross.EFCore

This assembly contains convenient classes that allow users to get EFCore up and running quickly. It also contains entity ChangeReporting functionality and implementation of DateLevelEntity pattern.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.1.1 36 3/20/2025
8.1.0 42 3/16/2025
8.0.1 102 3/9/2025
7.5.11 177 3/5/2025