Goodtocode.Domain 1.1.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Goodtocode.Domain --version 1.1.4
                    
NuGet\Install-Package Goodtocode.Domain -Version 1.1.4
                    
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="Goodtocode.Domain" Version="1.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Goodtocode.Domain" Version="1.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Goodtocode.Domain" />
                    
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 Goodtocode.Domain --version 1.1.4
                    
#r "nuget: Goodtocode.Domain, 1.1.4"
                    
#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 Goodtocode.Domain@1.1.4
                    
#: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=Goodtocode.Domain&version=1.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Goodtocode.Domain&version=1.1.4
                    
Install as a Cake Tool

Goodtocode.Domain

Domain-Driven Design (DDD) base library for .NET Standard 2.0+ and .NET

CI/CD Build, Test and Deploy

Goodtocode.Domain provides foundational types for building DDD, clean architecture, and event-driven systems. It includes base classes for domain entities, audit fields, domain events, and secured/multi-tenant entities. The library is designed for extensibility and can be integrated into any .NET Standard 2.0+ or .NET project.

Features

  • Domain entity base with audit fields (CreatedOn, ModifiedOn, DeletedOn, Timestamp)
  • Domain event pattern for eventual consistency and cross-context communication
  • Equality and identity management for aggregate roots
  • Secured entity base for multi-tenancy and ownership (OwnerId, TenantId)
  • Extension methods for authorization and ownership queries
  • Lightweight, dependency-free, and compatible with .NET Standard 2.0+ and .NET
  • Designed for use with EF Core, CosmosDb, custom repositories, and APIs

Quick-Start Steps

  1. Clone this repository
    git clone https://github.com/goodtocode/aspect-domain.git
    
  2. Install .NET SDK (latest recommended)
    winget install Microsoft.DotNet.SDK --silent
    
  3. Build the solution
    cd src
    dotnet build Goodtocode.Domain.sln
    
  4. Run tests
    cd Goodtocode.Domain.Tests
    dotnet test
    

Install Prerequisites

Top Use Case Examples

1. Basic Domain Entity with Audit Fields

using Goodtocode.Domain.DomainEntity;

public class MyEntity : DomainEntity<MyEntity>
{
    public string Name { get; private set; } = string.Empty;
    public int Value { get; private set; }

    public static MyEntity Create(Guid id, string name, int value)
    {
        return new MyEntity
        {
            Id = id == Guid.Empty ? Guid.NewGuid() : id,
            Name = name,
            Value = value,
            CreatedOn = DateTime.UtcNow
        };
    }
}

2. Secured Entity for Multi-Tenant and Ownership Scenarios

using Goodtocode.Domain.SecuredEntity;

public class DigitalAgentEntity : SecuredEntity<DigitalAgentEntity>
{
    protected DigitalAgentEntity() { }

    public Guid DigitalAssetId { get; private set; }
    public string? Name { get; private set; } = string.Empty;
    public string? Description { get; private set; } = string.Empty;
    public AgentStatus Status { get; private set; } = AgentStatus.Inactive;
    public ICollection<string> Tags { get; private set; } = [];
    public virtual Guid AgentPersonaId { get; private set; } = Personas.Monitor.Id;

    public static DigitalAgentEntity Create(Guid id, Guid digitalAssetId, Guid agentPersonaId, Guid tenantId, Guid ownerId, AgentStatus status, string? name = null, string? description = null)
    {
        return new DigitalAgentEntity()
        {
            Id = id == Guid.Empty ? Guid.NewGuid() : id,
            DigitalAssetId = digitalAssetId,
            AgentPersonaId = agentPersonaId,
            Status = status,
            Name = name,
            Description = description,
            TenantId = tenantId,
            OwnerId = ownerId
        };
    }

    public void Activate() => Status = AgentStatus.Active;
    public void Deactivate() => Status = AgentStatus.Inactive;
    public void Update(string? name, string? description)
    {
        Name = name;
        Description = description;
    }
}

3. Domain Events for Eventual Consistency

using Goodtocode.Domain.DomainEvent;

public class MyCreatedEvent : IDomainEvent<MyEntity>
{
    public MyEntity Entity { get; }
    public MyCreatedEvent(MyEntity entity) => Entity = entity;
}

// Usage in entity
var entity = MyEntity.Create(Guid.NewGuid(), "Test", 42);
entity.AddDomainEvent(new MyCreatedEvent(entity));

4. Secured Entity Authorization Extensions

using Goodtocode.Domain.SecuredEntity;

// Query for entities owned by a user
var ownedAgents = dbContext.Agents.IsOwner(userId);

// Query for entities authorized for a tenant or owner
var authorizedAgents = dbContext.Agents.WhereAuthorized(tenantId, userId);

Technologies

Version History

Version Date Release Notes
1.1.0 2026-Jan-20 Version bump, CI/CD improvements, props and targets updates
1.0.0 2026-Jan-19 Initial release

License

This project is licensed with the MIT license.

Contact

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

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
1.1.6 147 1/21/2026
1.1.4 73 1/23/2026
1.1.3 77 1/20/2026