Muonroi.EntityFrameworkCore.Configuration 1.0.0-alpha.16

This is a prerelease version of Muonroi.EntityFrameworkCore.Configuration.
dotnet add package Muonroi.EntityFrameworkCore.Configuration --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.EntityFrameworkCore.Configuration -Version 1.0.0-alpha.16
                    
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="Muonroi.EntityFrameworkCore.Configuration" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.EntityFrameworkCore.Configuration" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.EntityFrameworkCore.Configuration" />
                    
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 Muonroi.EntityFrameworkCore.Configuration --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.EntityFrameworkCore.Configuration, 1.0.0-alpha.16"
                    
#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.
#:package Muonroi.EntityFrameworkCore.Configuration@1.0.0-alpha.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.EntityFrameworkCore.Configuration&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.EntityFrameworkCore.Configuration&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.EntityFrameworkCore.Configuration

Composable EF Core entity configuration with a template method pattern for schema-divergent multi-tenancy.

NuGet License: Apache 2.0

In multi-tenant deployments each site shares 70–80% of the same schema but diverges on a handful of column names, lengths, and constraints. This package provides two mechanisms to express that divergence cleanly: a base class (MEntityConfigurationBase<TEntity>) that separates core schema from site-specific overrides via ordered template methods, and a [SiteColumn] attribute (applied by SiteColumnExtensions.ApplySiteColumnOverrides) for lightweight declarative per-site remapping. It depends only on Muonroi.Core.Abstractions and Microsoft.EntityFrameworkCore.Relational.

Installation

dotnet add package Muonroi.EntityFrameworkCore.Configuration --prerelease

Quick Start

Option A — virtual method overrides (MEntityConfigurationBase<TEntity>)

Derive one configuration class per entity in your core library and override site-specific hooks in each site project:

// Core library — shared schema for all sites
public class OrderConfiguration : MEntityConfigurationBase<Order>
{
    protected override void ConfigureTable(EntityTypeBuilder<Order> builder)
        => builder.ToTable("ORDERS").HasKey(e => e.Id);

    protected override void ConfigureCoreColumns(EntityTypeBuilder<Order> builder)
    {
        builder.Property(e => e.OrderNo).HasColumnName("ORDER_NO").HasMaxLength(50);
        builder.Property(e => e.Status).HasColumnName("STATUS").IsRequired();
    }
}

// Site "BRAVO" — override only what differs
public class BravoOrderConfiguration : OrderConfiguration
{
    protected override void ConfigureSiteColumns(EntityTypeBuilder<Order> builder)
        => builder.Property(e => e.OrderNo).HasColumnName("BOOKING_NUMBER").HasMaxLength(25);
}

Register via EF Core's assembly scan inside DbContext.OnModelCreating:

modelBuilder.ApplyConfigurationsFromAssembly(typeof(BravoOrderConfiguration).Assembly);

Option B — [SiteColumn] attribute + ApplySiteColumnOverrides

Annotate a site-specific entity class and call the extension once during model building:

public class BravoOrder
{
    public long Id { get; set; }

    [SiteColumn(Name = "BOOKING_NUMBER", MaxLength = 25)]
    public string? BookingNo { get; set; }

    [SiteColumn(IsRequired = true, DefaultValue = "N")]
    public string? Status { get; set; }

    // No attribute → convention: CONTAINER_NO
    public string? ContainerNo { get; set; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);
    modelBuilder.ApplySiteColumnOverrides<BravoOrder>("BRAVO");
}

Properties without [SiteColumn] are automatically mapped to UPPER_SNAKE_CASE by convention (e.g. ContainerNoCONTAINER_NO).

Features

  • Template method base classMEntityConfigurationBase<TEntity> calls five ordered hooks: ConfigureTableConfigureCoreColumnsConfigureCoreIndexesConfigureSiteColumnsConfigureSiteIndexes. Core methods are abstract; site methods are virtual no-ops, making them optional to override.
  • EF-native discovery — implements IEntityTypeConfiguration<TEntity>, so ApplyConfigurationsFromAssembly picks up all configurations without manual registration.
  • Declarative site column overrides[SiteColumn] attribute supports column name, max length, required constraint, default value, column type, and ignore (exclude from mapping).
  • UPPER_SNAKE_CASE conventionSiteColumnExtensions.ApplySiteColumnOverrides applies UPPER_SNAKE_CASE to all unmapped properties automatically, keeping convention consistent with the Dapper/ISiteColumnMap layer.
  • Shared naming conventionToUpperSnakeCase delegates to ColumnNamingConvention.ToUpperSnakeCase from Muonroi.Core.Abstractions, the single source of truth for column naming across EF Core and Dapper.

Configuration

No DI registration is required. MEntityConfigurationBase<TEntity> is consumed by EF Core's model-building pipeline directly. ApplySiteColumnOverrides is called inside DbContext.OnModelCreating.

API Reference

Type Purpose
MEntityConfigurationBase<TEntity> Abstract base implementing IEntityTypeConfiguration<TEntity>. Calls five template methods in a fixed order.
SiteColumnAttribute Attribute ([AttributeUsage(Property)]) for declarative per-site column overrides: Name, MaxLength, IsRequired, DefaultValue, HasColumnType, Ignore.
SiteColumnExtensions Static class. ApplySiteColumnOverrides<TEntity>(ModelBuilder, string siteId) reads [SiteColumn] attributes and applies overrides; falls back to UPPER_SNAKE_CASE convention for unannotated properties.

Samples

  • TestProject.Service — demonstrates [SiteColumn] attribute on BravoOrder and ApplySiteColumnOverrides wired in a minimal DbContext.
  • TestProject.Service.IntegrationTests — xUnit tests verifying [SiteColumn] attribute inspection and ApplySiteColumnOverrides column mapping via the EF Core in-memory provider.

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)
  • Muonroi.Core.Abstractions — provides ColumnNamingConvention.ToUpperSnakeCase, the shared naming source used by this package.
  • Muonroi.Data.EntityFrameworkCore — the higher-level EF Core package (MDbContext, audit timestamping, soft-delete). Use MEntityConfigurationBase<TEntity> inside a MDbContext subclass for the full stack.

License

Apache-2.0. See LICENSE-APACHE at the repository root.

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.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Muonroi.EntityFrameworkCore.Configuration:

Package Downloads
Muonroi.Data.EntityFrameworkCore

Entity Framework Core infrastructure for Muonroi: MDbContext with audit, soft-delete, multi-tenant filters, and repository base.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 117 6/22/2026
1.0.0-alpha.15 164 5/31/2026
1.0.0-alpha.14 160 5/15/2026
1.0.0-alpha.13 142 5/2/2026
1.0.0-alpha.12 85 4/2/2026
1.0.0-alpha.11 139 4/2/2026
1.0.0-alpha.9 77 3/30/2026
1.0.0-alpha.8 170 3/28/2026
1.0.0-alpha.7 71 3/27/2026
1.0.0-alpha.5 69 3/27/2026
1.0.0-alpha.4 76 3/27/2026
1.0.0-alpha.3 62 3/27/2026
1.0.0-alpha.2 64 3/26/2026