Fly.Shared.Core 1.0.2

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

Fly.Shared.Core

Core shared library for building FlyOS-compatible business app microservices on .NET 9.

Installation

<PackageReference Include="Fly.Shared.Core" Version="1.*" />

What's Included

Module Namespace What It Provides
Multi-tenancy Fly.Shared.Core.MultiTenancy ITenantContext, TenantContext, TenantEntity, AuditableEntity, TenantMiddleware, MultiTenantDbContext with automatic global query filters
Authentication Fly.Shared.Core.Auth ClaimsExtensions for extracting tenant/user from JWT, FlyAuthorizeAttribute for Cerbos-based authorization
Caching Fly.Shared.Core.Caching IFlyCache / RedisFlyCache — Redis-backed cache with consistent key conventions
i18n Fly.Shared.Core.I18n TranslatableEntity<T> base class for multilingual entities
Middleware Fly.Shared.Core.Middleware CorrelationIdMiddleware — injects/propagates X-Correlation-ID on every request
API Models Fly.Shared.Core.Models ApiResponse<T>, ApiResponse, ApiError, PagedRequest — standard envelope types

Quick Start

Service Registration

var builder = WebApplication.CreateBuilder(args);

// Registers TenantContext, IFlyCache (Redis), IHttpContextAccessor, MemoryCache
builder.Services.AddFlyCore();

// Add your DbContext using the shared multi-tenant base
builder.Services.AddDbContext<MyAppDbContext>(options =>
    options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));

var app = builder.Build();

// Resolves tenant from JWT sub-claim and populates ITenantContext
app.UseMiddleware<TenantMiddleware>();
app.UseMiddleware<CorrelationIdMiddleware>();
app.MapControllers();
app.Run();

Multi-Tenant Entity

using Fly.Shared.Core.MultiTenancy;

public class Project : TenantEntity
{
    public string Name { get; set; } = string.Empty;
    public bool IsActive { get; set; } = true;
}

Multi-Tenant DbContext

using Fly.Shared.Core.MultiTenancy;

public class MyAppDbContext : MultiTenantDbContext
{
    public MyAppDbContext(DbContextOptions<MyAppDbContext> options, ITenantContext tenant)
        : base(options, tenant) { }

    public DbSet<Project> Projects => Set<Project>();
}

MultiTenantDbContext automatically applies a global query filter e.TenantId == currentTenantId on all TenantEntity sets, and stamps TenantId on SaveChanges.

API Response Envelope

[ApiController]
[Route("api/projects")]
public class ProjectsController : ControllerBase
{
    [HttpGet]
    public IActionResult GetAll()
    {
        var projects = _service.GetAll();
        return Ok(ApiResponse<List<ProjectDto>>.Ok(projects));
    }

    [HttpPost]
    public IActionResult Create(CreateProjectRequest req)
    {
        if (!ModelState.IsValid)
            return BadRequest(ApiResponse.Fail("VALIDATION_ERROR", "Invalid input"));

        var project = _service.Create(req);
        return Created($"api/projects/{project.Id}", ApiResponse<ProjectDto>.Ok(project));
    }
}

Caching

public class ProjectService
{
    private readonly IFlyCache _cache;

    public async Task<Project?> GetByIdAsync(Guid id)
    {
        return await _cache.GetOrSetAsync(
            $"project:{id}",
            () => _db.Projects.FindAsync(id).AsTask(),
            TimeSpan.FromMinutes(15));
    }
}

Configuration

Add to appsettings.json:

{
  "Redis": {
    "ConnectionString": "localhost:6379"
  }
}

Dependencies

  • Microsoft.AspNetCore.App (framework reference)
  • Microsoft.EntityFrameworkCore 9.x
  • Microsoft.EntityFrameworkCore.Relational 9.x
  • Microsoft.Extensions.Caching.StackExchangeRedis 9.x
  • StackExchange.Redis 2.x
  • FluentValidation.AspNetCore 11.x
  • OpenTelemetry.Extensions.Hosting 1.x
  • OpenTelemetry.Instrumentation.AspNetCore 1.x
  • Fly.Shared.Messaging — MassTransit/RabbitMQ wiring and platform event contracts. Depends on this package.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 Fly.Shared.Core:

Package Downloads
Fly.Shared.Messaging

MassTransit/RabbitMQ wiring and platform event/command contracts for FlyOS business app integration. Provides AddFlyMessaging() extension, exponential retry, in-memory outbox, and all platform event records (TenantCreated, UserCreated, LicenseUpdated, etc.).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.9.0 97 5/20/2026
1.0.5 119 4/29/2026
1.0.2 109 4/28/2026
1.0.0 123 4/1/2026