Fly.Shared.Core
1.0.2
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
<PackageReference Include="Fly.Shared.Core" Version="1.0.2" />
<PackageVersion Include="Fly.Shared.Core" Version="1.0.2" />
<PackageReference Include="Fly.Shared.Core" />
paket add Fly.Shared.Core --version 1.0.2
#r "nuget: Fly.Shared.Core, 1.0.2"
#:package Fly.Shared.Core@1.0.2
#addin nuget:?package=Fly.Shared.Core&version=1.0.2
#tool nuget:?package=Fly.Shared.Core&version=1.0.2
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.EntityFrameworkCore9.xMicrosoft.EntityFrameworkCore.Relational9.xMicrosoft.Extensions.Caching.StackExchangeRedis9.xStackExchange.Redis2.xFluentValidation.AspNetCore11.xOpenTelemetry.Extensions.Hosting1.xOpenTelemetry.Instrumentation.AspNetCore1.x
Related Packages
- Fly.Shared.Messaging — MassTransit/RabbitMQ wiring and platform event contracts. Depends on this package.
| Product | Versions 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. |
-
net9.0
- FluentValidation.AspNetCore (>= 11.3.1)
- Microsoft.EntityFrameworkCore (>= 9.0.3)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.3)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 9.0.3)
- Microsoft.Extensions.Http.Resilience (>= 9.0.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.1)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.15.1)
- StackExchange.Redis (>= 2.12.8)
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.