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.GlobalUniqueIndexto 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.