What is Bogus?

Tohid haghighi
5 min readMay 30, 2024

Bogus is a fake data generator for .NET, which we can use to generate simple, but realistic data. It is based on the faker.js library, which is very popular in the JS world, and it is widely used for generating massive amounts of fake data. Syntactically, Bogus is inspired by Fluent Validation, and we will see a lot of similarities when configuring Bogus in C#.

Faker

Why Use Bogus?

What are the benefits of using Bogus? There are lots of them, but the most important one is that we can save ourselves a lot of time that we would spend by creating fake data manually. With Bogus, we can specify our classes and their relations, and configure Bogus rules to generate fake data.

That said, we can use built-in generators from Bogus to create different data like addresses, phone numbers, emails, etc. On top of that, we can realistically connect our data. For example, if we have an Employee class that has FirstName and LastName fields, we can use those fields to generate Email for that object. That way, our data will look better when we display it.

Bogus has a wide specter of usages. We can use it for mocking our test data, seeding fake data to our databases, and even integrating it with Entity Framework Core, which we will see in this article.

First, we will start by preparing the environment and creating classes that we…

--

--

Tohid haghighi

Full-Stack Developer | C# | .NET Core | Vuejs | TDD | Javascript