Fuda 0.0.1
dotnet add package Fuda --version 0.0.1
NuGet\Install-Package Fuda -Version 0.0.1
<PackageReference Include="Fuda" Version="0.0.1" />
<PackageVersion Include="Fuda" Version="0.0.1" />
<PackageReference Include="Fuda" />
paket add Fuda --version 0.0.1
#r "nuget: Fuda, 0.0.1"
#:package Fuda@0.0.1
#addin nuget:?package=Fuda&version=0.0.1
#tool nuget:?package=Fuda&version=0.0.1
Fuda
Fuda is a flexible tagging library for .NET applications.
It is inspired by the store/manager design used in ASP.NET Core Identity, and supports:
- tagging any entity type (
Taggable) - optional per-user tagging (
Tagger) - optional tag grouping by
Context(for example:skills,interests,bookmarks) - store abstraction so you can swap persistence implementations
- an Entity Framework Core implementation (
Fuda.EntityFrameworkCore) - batch tag loading APIs to avoid N+1 query problems
Core concepts
- Tag: the tag itself (
Name,NormalizedName, and ID) - Tagging: relation between a tag and a taggable entity (optionally with tagger and context)
- Taggable: the target entity to be tagged
- Tagger: optional actor that created/owns the tagging
- Context: optional category key for separating tag sets
Package structure
src/Fuda: core abstractions (ITagStore,ITaggingStore,ITagNormalizer,TagManager)src/Fuda.EntityFrameworkCore: EF Core stores, DI extensions, model configuration helpers
Quick start (Entity Framework Core)
1. Define your entities
public class Tag
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string NormalizedName { get; set; } = string.Empty;
}
public class Tagging
{
public int Id { get; set; }
public int TagId { get; set; }
public int TaggableId { get; set; }
public int? TaggerId { get; set; }
public string? Context { get; set; }
}
public class BlogPost
{
public int Id { get; set; }
public string Title { get; set; } = string.Empty;
}
2. Create your DbContext
Use FudaDbContext<...> as your base class and call ConfigureFuda.
using Microsoft.EntityFrameworkCore;
using Fuda.EntityFrameworkCore;
public class BlogDbContext : FudaDbContext<Tag, Tagging, object, BlogPost, int>
{
public DbSet<BlogPost> BlogPosts => Set<BlogPost>();
public BlogDbContext(DbContextOptions<BlogDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Tag>(entity =>
{
entity.HasKey(x => x.Id);
entity.Property(x => x.Name).IsRequired();
entity.Property(x => x.NormalizedName).IsRequired();
});
modelBuilder.Entity<Tagging>(entity =>
{
entity.HasKey(x => x.Id);
entity.Property(x => x.TagId).IsRequired();
entity.Property(x => x.TaggableId).IsRequired();
});
modelBuilder.ConfigureFuda<Tag, Tagging, int>();
}
}
3. Register Fuda in DI
using Fuda.EntityFrameworkCore;
builder.Services.AddFuda<Tag, Tagging, object, BlogPost, int>()
.AddEntityFrameworkStores<BlogDbContext>(
getTaggableIdFunc: post => post.Id);
AddEntityFrameworkStores also accepts property name overrides if your schema uses different names.
4. Inject and use TagManager
using Fuda;
public class PostsService
{
private readonly TagManager<Tag, Tagging, object, BlogPost, int> _tagManager;
public PostsService(TagManager<Tag, Tagging, object, BlogPost, int> tagManager)
{
_tagManager = tagManager;
}
public async Task AddTagsAsync(BlogPost post)
{
await _tagManager.AddTagAsync(post, "ASP.NET Core");
await _tagManager.AddTagAsync(post, "Tutorial", context: "category");
var tags = await _tagManager.GetTagsAsync(post);
await _tagManager.ReplaceTagsAsync(post, new[] { "dotnet", "web" });
await _tagManager.RemoveTagAsync(post, "web");
}
}
API overview
Add/Remove/Replace
AddTagAsync(taggable, tagName, context?)AddTagAsync(tagger, taggable, tagName, context?)RemoveTagAsync(taggable, tagName, context?)RemoveTagAsync(tagger, taggable, tagName, context?)ReplaceTagsAsync(taggable, tagNames, context?)ReplaceTagsAsync(tagger, taggable, tagNames, context?)
Read
GetTagsAsync(taggable, context?)GetTagsAsync(tagger, taggable, context?)GetTagCountsAsync(context?)GetTagCountsAsync(tagger, context?)
Search
GetTaggableIdsAsync(tagNames, context?)- Find entities that have all of the specified tagsGetTaggableIdsAsync(tagger, tagNames, context?)- Find entities tagged by the tagger with all of the specified tags
// Find blog posts that have BOTH "csharp" AND "dotnet" tags
var postIds = await tagManager.GetTaggableIdsAsync(new[] { "csharp", "dotnet" }, "tags");
Batch loading (N+1 prevention)
GetTagsForManyAsync(taggables, context?)GetTagsForManyAsync(tagger, taggables, context?)
Use batch loading when you need tags for many entities in list pages.
var posts = await context.BlogPosts.OrderByDescending(p => p.Id).ToListAsync();
var tagMap = await tagManager.GetTagsForManyAsync(posts);
// tagMap[postId] => IReadOnlyList<Tag>
Tagger and Context patterns
Tagger
Use tagger overloads to isolate taggings by user/account.
await tagManager.AddTagAsync(currentUser, post, "bookmark", context: "bookmarks");
var myTags = await tagManager.GetTagsAsync(currentUser, post, context: "bookmarks");
Context
Use contexts to keep independent tag namespaces on the same entity.
await tagManager.AddTagAsync(post, "C#", context: "skills");
await tagManager.AddTagAsync(post, "Featured", context: "status");
Normalization
TagManager uses ITagNormalizer to normalize names before creating/searching tags.
- default implementation:
UpperInvariantTagNormalizer - purpose: prevent duplicates like
csharpvsCSHARP
You can replace it in DI with your own implementation.
Using custom stores (without EF Core)
Fuda core is persistence-agnostic.
Implement these interfaces for your storage backend:
ITagStore<TTag, TKey>ITaggingStore<TTagging, TTag, TTaggable, TTagger, TKey>
Then construct/inject TagManager<...> with your store implementations and an ITagNormalizer.
Example project
A runnable sample app is available at:
examples/BlogApp
It demonstrates DI registration, EF Core mapping, batch loading, and tag display/filtering.
Development
From the repository root:
dotnet build
dotnet test
Test coverage
Collect coverage (Coverlet collector is installed in test projects):
dotnet test --collect:"XPlat Code Coverage" --results-directory ./TestResults
Generate an HTML report with ReportGenerator (local tool):
dotnet tool restore
dotnet tool run reportgenerator \
-reports:"./TestResults/**/coverage.cobertura.xml" \
-targetdir:"./TestResults/CoverageReport" \
-reporttypes:"Html"
| Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fuda:
| Package | Downloads |
|---|---|
|
Fuda.EntityFrameworkCore
A tagging library for .NET applications that allows for custom tagging along dynamic contexts. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1 | 166 | 4/20/2026 |