Configs2026年7月13日·1 分钟阅读

Bogus — Realistic Fake Data Generator for .NET

A simple and powerful fake data generator for C#, F#, and VB.NET, based on and compatible with the popular faker.js library.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Bogus Overview
直接安装命令
npx -y tokrepo@latest install a9aad544-7e94-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Bogus is a .NET port of the popular faker.js library, providing a fluent API for generating realistic fake data. It is widely used for seeding databases, populating test fixtures, and prototyping applications without relying on production data.

What Bogus Does

  • Generates fake data across 50+ categories including names, addresses, finance, and lorem text
  • Provides a strongly-typed fluent API for defining generation rules per property
  • Supports 40+ locales for internationalized fake data
  • Produces deterministic output with configurable seed values for reproducible tests
  • Works with records, classes, and anonymous types in C#, F#, and VB.NET

Architecture Overview

Bogus uses a fluent builder pattern where Faker<T> maps generation rules to properties via lambda expressions. Under the hood, each data category (Name, Address, Commerce, etc.) is a dataset class loaded from locale-specific JSON files. A Mersenne Twister PRNG with optional seed ensures reproducibility.

Self-Hosting & Configuration

  • Install via NuGet: dotnet add package Bogus
  • No external services or configuration required — it is a pure library
  • Set a seed with new Faker<T>().UseSeed(1234) for deterministic output
  • Use Faker.GlobalUniqueIndex to track unique values across instances
  • Add locale-specific data with new Faker<T>("de") or any supported locale code

Key Features

  • Fluent API with full IntelliSense support in Visual Studio and Rider
  • Over 50 built-in data generators (Phone, Company, Vehicle, Hacker, etc.)
  • Supports complex object graphs with nested fakers
  • Lightweight with no external dependencies
  • Extensively tested with high community adoption across the .NET ecosystem

Comparison with Similar Tools

  • Faker.js — The JavaScript original; Bogus is its .NET port with idiomatic C# API
  • AutoFixture — Focuses on anonymous test data; Bogus produces human-readable realistic data
  • NBuilder — Object builder for tests; less focus on realistic data categories
  • GenFu — Simpler .NET fake data library; Bogus has more categories and locales

FAQ

Q: Can Bogus generate unique values? A: Yes, use the .UniqueIndex property or the f.IndexFaker to ensure uniqueness across generated instances.

Q: Does Bogus work with Entity Framework? A: Yes, it is commonly used in EF Core seed methods to populate databases with test data.

Q: How do I generate a list of fake objects? A: Call faker.Generate(100) to create a list of 100 fake objects in one call.

Q: Is Bogus suitable for production use? A: It is designed for testing, development, and demos — not for generating production data.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产